Created
July 30, 2014 15:22
-
-
Save l3robot/3985e40fb8e941f90c5c to your computer and use it in GitHub Desktop.
Python script to find false .jpg files in a directory. It finds PNG files -- python 3.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| a = input("Enter the directory name here : "); | |
| b = os.listdir(a) | |
| for i in b: | |
| c = a + i | |
| f = open(c, "rb") | |
| image = f.read() | |
| if image[0] == 0x89 and image[1] == 0x50: | |
| print("Will transform " + i + " in PNG, because it's a PNG file...") | |
| name = i[0:-4] + ".png" | |
| command = "mv " + a + i + " " + a + name | |
| os.system(command) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment