ShriRam Changed status to publish August 21, 2023
import os
# Rename a file from test1.txt to test2.txt
os.rename( “test2.txt”, “foo.txt” )
# Delete file test2.txt
os.remove(“foo.txt”)
# Create a directory “test”
os.mkdir(“test”)
# Changing a directory to “/home/newdir”
os.chdir(“/home/newdir”)
# Changing a directory to “/home/newdir”
os.chdir(“E:/PythonProjects/ShriRam-Hello/test”)
# This would give location of the current directory
print(os.getcwd())
# Changing a directory to “/home/newdir”
os.chdir(“..”)
# This would give location of the current directory
print(os.getcwd())
# Changing a directory to “/home/newdir”
os.chdir(“test”)
# This would give location of the current directory
print(os.getcwd())
os.rmdir(‘test’)
ShriRam Changed status to publish August 21, 2023