jmquintana79
1/5/2020 - 10:09 PM

os path operator

Basic usage of os library to interactuate with the files system.

## CURRENT FOLDER
import os
cwd = os.getcwd()
 
## LIST FILES INTO A FOLDER
import os
lfiles = os.listdir(folder_files)
 
## RENAME FILE
import os
os.rename('old_name.txt', 'new_name.kml')
 
## LIST FILES, FOLDERS AND PATHS RECURSIVELLY IN A TREE FILE SYSTEM
# collect recurvelly list of files
from os import walk
for (dirpath, dirnames, filenames) in walk(folder):
    print(filenames)