Python Scripts: Difference between revisions

Line 703:
 
directory = sys.argv[1]
 
 
# Code for Archiving existing files & save list of files
Line 734 ⟶ 733:
fn1, ext1 = os.path.splitext(file)
fn2, ext2 = os.path.splitext(fn1)
ftype = imghdr.what(file)
 
if notftype ext1== None:
ftypeprint(file, ="Unsupported imghdr.what(file")
else:
newname = file + "." + ftype
if not ext1:
filechk2 = Path(newname)
if filechk2.is_file():
Line 744 ⟶ 746:
shutil.move(file, newname)
print (file, "has no ext, Appending:", ftype)
else:
if not ext2:
continue
print("1 Extension only")
elif ext2 == ext1:
filechk = file.replace(extext1,ftype)
filechk2 = Path(filechk)
if filechk2.is_file():
Line 757 ⟶ 759:
print (file, "has 2 Same ext, Removing:", ext2)
elif ext2 != ext1:
filechk = file.replace(extext1,ftype)
filechk2 = Path(filechk)
if filechk2.is_file():
Line 803 ⟶ 805:
 
print("Correcting extension done")
 
</syntaxhighlight>