mv Command using system call in Python

Jul 23, 2015 at 8:48am
I'm trying to move a file using mv command in Python. But I'm getting error.I've tried following code:

system("mv /home/comp-sl1-25/.local/share/Trash/files/"+filename" /home/comp-sl1-25/RecoveredFile");

I want to move a file(named 'filename'- its a string variable) from Trash folder to recovery folder.
Basically I'm trying to restore files from trash using Python. So if you have any other way to restore files from trash using Python then also provide the code.
Thanks in advance :D
Last edited on Jul 23, 2015 at 9:12am
Jul 23, 2015 at 11:10am
Do not use system() for that.

Read
man 2 rename

and
http://www.Python/reference/cstdio/rename/
Last edited on Jul 23, 2015 at 11:10am
Jul 25, 2015 at 7:35pm
Like Keskiverto said, you shouldn't be using system() but as far as the issue look closely at your string "mv /home/comp-sl1-25/.local/share/Trash/files/"+filename" /home/comp-sl1-25/RecoveredFile" notice how after filename you are missing a +? Though this won't even fix the issue it will just fix how a string should be.
Last edited on Jul 25, 2015 at 7:35pm
Topic archived. No new replies allowed.