5 Copies all .ibw files contained in a folder and its subfolders into a single folder. Useful for force maps.
8 python FMjoin.py origindir destdir
11 Alberto Gomez-Casado (c) 2010, University of Twente (The Netherlands)
12 This program is released under the GNU General Public License version 2.
21 print 'You must at least specify origin and destination folders.'
26 if os.path.exists(origin):
27 if os.path.exists(dest):
28 if os.listdir(dest)!=[]:
29 print 'Destination folder is not empty! Use another folder.'
32 print 'Destination folder does not exist, will create it'
35 print 'You provided a wrong origin folder name, try again.'
37 origin=os.path.abspath(origin)
38 dest=os.path.abspath(dest)
40 for root, dirs, files in os.walk(origin):
41 for filename in files:
42 if filename.split('.')[1]!="ibw":
44 filepath=os.path.join(root,filename)
45 #to avoid overwriting, we collapse unique paths into filenames
46 rawdest=filepath.split(os.path.commonprefix([origin, filepath]))[1]
47 rawdest=rawdest.replace('/','') #for linux
48 rawdest=rawdest.replace('\\','') #for windows
49 destfile=os.path.join(dest,rawdest)
50 print 'Copying '+rawdest
51 shutil.copy(filepath,destfile)
55 if __name__ == '__main__':
56 sys.exit(main(*sys.argv))