×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    37

    Backup complete Drive like C:/ or E:/

    Hi there,

    i'm looking for a way to backup C:/ or E:/ with all folders and subfolders...etc.

    But i only found some solutions to copy single files or copy a specific folder.
    I dont know which folders are on c currently and there may be some new ones from time to time, so makes no sense to list them down....

    any solution for that?

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Backup complete Drive like C:/ or E:/

    Hi,

    Well, you could use the listdir function from the os module to find out what directories are in a certain directory (in this case in C or E) at any time. Details here and here's an example:
    Code:
    import os
    
    print os.listdir("C:\\")

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,569

    Re: Backup complete Drive like C:/ or E:/

    But do note that Symbian Platform Security prevents access to some directories (unless you have AllFiles capability and TCB if you also need to write to them).

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    37

    Re: Backup complete Drive like C:/ or E:/

    thanks for your help first!

    so theres no command to copy all contents from a drive like c:/?

    i'd have to use os.listdir("C:\\") to get a list of all directorys and files in root ['folder_a','b.txt','folder_c','folder_d']

    i used an example i found and replaced the source directory, but it doesnt work?
    it creates a file called backup on e:/ with 50kb?

    whats wrong here?

    Code:
    import os, e32, appuifw
    
    
    folder = "E:\\" 		# source directory
    files = os.listdir(folder) 	# list all files inside the folder
    target = 'E:\\Backup' 		# target directory
    count = len(files) 		# How much files you have in the folder
     
    for i in range(count):
     
        t_file = folder + "\\" + files[i]
        
        e32.file_copy(target, t_file)
     
        
    appuifw.note(u"Backup complete!")

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Backup complete Drive like C:/ or E:/

    hello kwik

    the code you posted is not intended to copy the contents of the E:\\ directory.

    The code copies all that is there inside the E:\\ directory i.e. the files which are not inside any folders.

    For copying every content you need to copy all the folders separately and copy that to the specified folder.

    Hope you got my point.

    Enjoy Pythoning
    Gaba88

  6. #6
    Registered User
    Join Date
    Jun 2008
    Posts
    37

    Re: Backup complete Drive like C:/ or E:/

    hey gaba88,

    now i know the problem, and how to solve it

    ..but thats too much for me.. at the moment..

    Think i'm gonna copy all contents with a filexplorer, that also does the job.
    not as easy as with a script, but it works.

    Thanks anyway for all your help!

  7. #7
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Backup complete Drive like C:/ or E:/

    If you're using PyS60 1.9.0 or later and are able to get the necessary capabilities to avoid any permission-related errors that might arise you can use the copytree function (which doesn't seem to be implemented in PyS60 upto 1.4.5) from the shutil module (documented here):
    Code:
    import shutil
    
    shutil.copytree("C:\\", "E:\\copy") #Copies everything from C to E:\copy

  8. #8
    Registered User
    Join Date
    Jun 2008
    Posts
    37

    Re: Backup complete Drive like C:/ or E:/

    Code:
    import shutil
    
    shutil.copytree("C:\\", "E:\\copy")
    that is what i was looking for!

    But i have python 1.45 and wont uprade since some programms will stop working with python 1.9.

    Dont know why? but so it is...


    Thanks anyway, perhaps when version 2.0 comes out..

Similar Threads

  1. complete backup solution
    By razvu in forum General Development Questions
    Replies: 2
    Last Post: 2009-03-17, 06:35
  2. Replies: 2
    Last Post: 2007-12-26, 09:51
  3. SMS & Complete phone Backup Software for Nokia 6300
    By lunkers in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2007-07-20, 16:11
  4. target drive letter for SISPATCH
    By geran in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2003-11-07, 13:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×