abspath - It returns the absolute path of current working directory with file name. file_name = 'GFG.txt' print(os.path.abspath(file_name)) >>> /home/geeks/Desktop/gfg/GFG.txt chdir Change directory. file_name = 'GFG.txt' os.chdir("/home/geeks/") print(os.path.abspath(file_name)) >>> /home/geeks/GFG.txt #refer previous code basename - It returns only the file name except for the parent path. - S..