Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os,shutil
- def checkFileFormat(fileFormat,sourceDir):
- for i in range(len(os.listdir(sourceDir))):
- File = os.listdir(sourceDir)[i]
- (fn,ff) = File.split(".")
- xdir = fileFormat+"/"
- if ( ff == fileFormat ):
- src_dir = sourceDir+str(File)
- dst_dir = xdir+str(File)
- shutil.move(src_dir,dst_dir)
- else:
- print("File format does not exists!")
- break
- print("**DONE**")
- exit()
- while( True ):
- file_format = input("File format: ")
- source_dir = str(input("Source directory: "))
- source_dir += "/"
- if ( file_format.isdigit() ):
- print("Numbers is not a format!")
- else:
- break
- if ( not os.path.exists(source_dir) ):
- print("Directory doesn't exists!")
- else:
- break
- while( True ):
- try:
- checkFileFormat(file_format,source_dir)
- except Exception:
- pass
- else:
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement