moving multiple directories

DataSmash rdh at
Mon Apr 16 18:21:53 CEST 2007

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
delete as well.  Much longer process when you have hundreds of
gigabytes of data.

Thanks for your help!

More information about the Python-list mailing list