Solved

Program and method for moving files between drives

Posted on 2007-11-14
5
366 Views
Last Modified: 2012-06-22
I have 4 hard drives of backups of large files.  They are in no order.  I would like to arrange them alphabetically by file name amongst the drives. Only I don't have space to put them all in one location and then sort them out. Is there an automated way or script that would sort and move these files for me.

Thanks,
0
Comment
Question by:mgjust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 17

Assisted Solution

by:ramrom
ramrom earned 20 total points
ID: 20286901
Why? What advantage do you get from doing this? Beware that you could get trapped in a situation where a very large file might not fit at the end of drive 1, thus forcing it to drive 2 and leaving a big unused space on drive 1.

How much drive space is there and how much space do the files take up?

Would it not be better to maintain a directory of all files in alphabetic order rather than physically sorting them?

And is this a static backup, or are files added/deleted from time to time.
0
 

Author Comment

by:mgjust
ID: 20286991
Its not static.
The advantage would be to find said files easily.

Is there an easy way to create a directory?
Thanks,
0
 
LVL 15

Expert Comment

by:efn
ID: 20287183
Assuming the number of files is not too huge, it would certainly be possible to write a script that would create an alphabetical index of the files.  I don't know of any off-the-shelf solution.
0
 
LVL 29

Accepted Solution

by:
pepr earned 410 total points
ID: 20287500
Here the example show only how to get the list of the files in separated directories. You can use shutil.copy2() for moving the files to the selected destination (http://docs.python.org/lib/module-shutil.html#l2h-2296). However, sorting is not necessary for the task... unless you want to display the files and let the user choose only some of them.
import os
 
def myCmp(a, b):
    '''Used for comparison of tuples based on first items.'''
    return cmp(a[0], b[0])
 
 
# The list of backup directories. Here the four drives are simulated in 
# four directories.
dirs = ['c:/tmp/backup1', 'c:/tmp/backup2', 'c:/tmp/backup3', 'c:/tmp/backup4']
 
# Build lst of tuples with bare name and full name. It assumes that all files
# in the directories are backup files. Otherwise, the list must be filtered 
# first.
lst = []
for d in dirs:
    lst.extend( (bare, os.path.join(d, bare)) for bare in os.listdir(d) )
 
# Now sort the list.
lst.sort(myCmp)
 
# Print the sorted bare names plus the full path to the file.
for bare, full in lst:
    print bare, full

Open in new window

0
 
LVL 29

Assisted Solution

by:pepr
pepr earned 410 total points
ID: 20287531
The easy way of making the directory that does not exist is:

    os.mkdir(path)

or
 
    os.makedirs(path)         # makes also upper subdirectories if they do not exist

See http://docs.python.org/lib/os-file-dir.html#l2h-2688 
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…
This Micro Tutorial will teach you how to reformat your flash drive. Sometimes your flash drive may have issues carrying files so this will completely restore it to manufacturing settings. Make sure to backup all files before reformatting. This w…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question