Jump to content

Python Scripts: Difference between revisions

Line 687:
<pre>
#!/usr/bin/env python3
# Need to write Results to a file in script dir
import os
import imghdr
Line 693 ⟶ 694:
 
directory = sys.argv[1]
 
# Need to add a section for no extensions
# Need to write Results to a file in script dir
 
for root, dirs, files in os.walk(directory):
Line 706 ⟶ 704:
 
# find files with the (incorrect) extension to rename
if ftype != ext:
if ftype != Noneext:
if ftype != None:
 
# rename the file
shutil.move(file, file.replace(ext,ftype))
print (file, ext, ("=>"), ftype)
 
# in case it can't be determined, mention it in the output
else:
print("could not determine: "+file)
else:
print ("couldname, not determine:"correct extension"+file)
else:
print (namefile, "correctNo Extension extensiondetected")
 
print ("done")
Cookies help us deliver our services. By using our services, you agree to our use of cookies.