How can I do the equivalent of mv in Python?
mv "path/to/current/file.foo" "path/to/new/destination/for/file.foo"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
os.rename(),os.replace(), orshutil.move()All employ the same syntax:
"file.foo") must be included in both the source and destination arguments. If it differs between the two, the file will be renamed as well as moved.os.replace()will silently replace a file even in that occurrence.shutil.movesimply callsos.renamein most cases. However, if the destination is on a different disk than the source, it will instead copy and then delete the source file.