shash_python-for-sysadmins
shash_python-for-sysadmins
os.sep gives the current working directory as the sting os.path.join ("folder1", "folder2", This takes the folder list and joins
value. "folder3", "filename") them to give a path name
os.getcwd() gives the current working directory as the sting os.path.abspath("filename") this gives the absolute path of the file
value os.path.isabs("filepath") gives true of false for the abs path
os.chdir("Dir loc") takes in directory location and changes the
os.path.relpath("filepath") gives relative path for the 2 paths
working directory
you give.
os.listdir("filename") gives s the list of all the files.
os.path.exists("Filename") gives true or false for the file name
os.makedirs("folderna creates the folders.
os.path.isfile("filepath") true if the path is file
mes")
os.path.isdir("filepath") true if the path is folder
os.unlink("filename") deletes a file
os.path.getsize("filename") gives the size in bytes
os.rmdir("folder") deletes a folder.
shutil