looks like you already have some good answers to the query, but figured I'd chime in as well. here is my python script for almost the same thing. it walks all subdirs in a dir, and causes all the files within them to erupt into the base dir.
Code:
#!/usr/bin/env python
#usage: volcano.py <basedirpath>
import os, sys, shutil
def main():
for a in sys.argv:
arg = os.path.normpath(a)
for root, dirs, files in os.walk(arg, False):
for f in files:
src = os.path.join(root, f)
fname = os.path.split(src)[1]
try:
shutil.move(src, os.path.join(arg, fname))
print "moved %s to %s" %(src, os.path.join(arg, fname))
except Exception, e:
print "Errpr moving file %s to %s" %(src, os.path.join(arg, fname))
print "Exception: ", e
if __name__ == "__main__":
main()
Bookmarks