Making backup of a folder using PyS60

by Rafael Tavares

Some days ago I was reading a thread on the Python Discussion Boards, which the user told he wanted to backup a private folder for keeping his N-Gage files saved. Well, that is not possible because Private folders can’t be accessed when using Python for S60. Anyway, I presented him the command from e32 module for copying files.

After that, I was thinking in a code for making backup of a regular folder. I realized that it could be done easily using a loop. But before implementing a loop, obviously, I tried a simple code for testing the command:

Ok. The command was working fine!

Now I need to get all files from a folder and set a loop for running through all of them and copying each one.

So, let’s use a for loop:

That code should work, now!

First we used os.listdir for getting all files from the folder and then did the loop for getting those files. Finally: use e32.file_copy to make the backup.

For enhancing the code, you could also have queries for user to define the folders they want ;)

I hope you all like my first post here :)

*Big thanks to Pankaj and Jouni for support!

No related posts.