There is a problem with the stored hard disk, most of the picture files are OK after the system reboot, but there is a little damage. Python makes it easy to find all the corrupted files from a few terabytes of files.
Make sure you are using a Python version 2.7.9 or above or more than 3.4
PIP is already installed if you ' re using Python 2 >=2.7.9 or Python 3 >=3.4 binaries downloaded fr Om python.org, but you'll need to upgrade PIP.
PIP is installed by default in Python version 2.7.9 or above or 3.4 python
1) Install filetype extensions using commands
Pip Install filetype
2) Use the following code to export the list of corrupted files
Just change the path you want to look for in the directory you want to find.
#-Coding:utf-8-ImportIMGHDRImportOSImportdatetimeImport TimeImportCodecsImportfiletypecheckstart_date= Datetime.datetime.now () + datetime.timedelta (days =-77)#Check how many days the file is withinCheckstart_str = Checkstart_date.strftime ("%y-%m-%d") file= Codecs.open ('D:\imglist.txt','W','Utf-8')#write the absolute path of the damaged file to TXT file & prevent garbledPath ='D:\IMG\\' #directories to check forPrint('Start checking') forRT, dirs, filesinchOs.walk (path): forFinchFiles:fname=Os.path.splitext (f) Statinfo=os.stat (rt+'\\'+f)ifTime.strftime ("%y-%m-%d", Time.localtime (statinfo.st_mtime)) >=Checkstart_str:kind= Filetype.guess (rt+'\\'+f)ifKind isNone:file.write (Rt+'\\'+f+'\ r \ n') Print(rt+'\\'+f)Print('End Checking') File.close ()
Python3 use the filetype package to find all corrupted files in the specified directory (Pictures, videos, audio, etc.)