Google
 

9/29/09

use python to manipulate large number of files in a directory.

When you have tons of files in a folder and want to manipulate them together, you will have trouble. For example if you use "mv" or "cp", you will get "Arguments are too long". You can use python to do this.

here is how to do it.

invoke python first.

>>> import os, glob, shutil
>>> for file in glob.glob('./directory1/*.tif'):
                     shutil.copy(file, './temp')

this should work.

No comments: