3 copy_dir =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r0p10/" 5 for root, dirs, files
in os.walk(copy_dir):
9 dest_dir = from_dir.replace(
"/lbne/data/users/",
"/pnfs/lbne/scratch/users/");
11 print "Copying "+os.path.join(root,file)+
" TO "+dest_dir
14 folders = dest_dir.split(
"/")
16 for i
in range(0,len(folders)):
17 temp = os.path.join(temp,folders[i])
18 if not os.path.exists(temp):
20 os.system(
"ifdh mkdir "+temp)
24 if os.path.exists(os.path.join(dest_dir,file)):
25 if (os.path.getsize(os.path.join(dest_dir,file)) ==
26 os.path.getsize(os.path.join(from_dir,file))):
27 print dest_dir+file+
": File already exists and is identical..skipping" 28 if (os.path.getsize(os.path.join(dest_dir,file)) >
29 os.path.getsize(os.path.join(from_dir,file))):
30 print dest_dir+file+
": File already exists and is bigger than source file..skipping" 31 if (os.path.getsize(os.path.join(dest_dir,file)) <
32 os.path.getsize(os.path.join(from_dir,file))):
33 print dest_dir+file+
": File already exists but is smaller than source file... removing old file and replacing." 34 os.remove(dest_dir+file)
36 if not os.path.exists(os.path.join(dest_dir,file)):
37 os.system(
"ifdh cp "+os.path.join(from_dir,file)+
" "+os.path.join(dest_dir,file))