Rohith
0
Q:

python move file

# To move a file in Python, use one of the following:
import os
import shutil

os.rename("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
shutil.move("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
os.replace("path/to/current/file.foo", "path/to/new/destination/for/file.foo")

# In the first two cases the directory in which the new file
# is being created must already exist.
8
import os
import shutil

os.rename("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
shutil.move("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
os.replace("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
1
import os
import shutil

os.rename("current_path/foo.bar", "new_path/foo.bar")
shutil.move("current_path/foo.bar", "new_path/foo.bar")
os.replace("current_path/foo.bar", "new_path/foo.bar")
2
import os, shutil
#move picture.png from /some/dir/ to /another/dir/Pictures/
shutil.move('/some/dir/picture.png', '/another/dir/Pictures/')
1

New to Communities?

Join the community