moving multiple directories

DataSmash rdh at new.rr.com
Mon Apr 16 12:21:53 EDT 2007


Hi,
I need to organize thousands of directories full of files.
I want to move these directories into other subdirectories.
For example, all the directories that start with 01, move to
a directory named "one", all directories that start with 02, move
to a directory name "two", and so on....

I can't seem to find any easy way to do this.
Looks like shutil.move only lets you move if the subdirectory DOES
NOT exist, so after the first directory moves, the script blows up on
the second move.
I guess you could use shutil.copy or shutil.copytree but then you have
to
delete as well.  Much longer process when you have hundreds of
gigabytes of data.

Thanks for your help!
R.D.




More information about the Python-list mailing list