Find Files Of Specific Type From Hard Drive - But Only Update Data If Needed
Implement in Delphi 10.4 (or compatible) a non visual application that takes as a command line parameter a hard disk letter (e.g. "app.exe -path: C" would analyze the C:\ drive).
It will then proceed to analyze the content of that given hard drive and produces the an output text file within the app's executable folder that has the following content, in a text only format of your choosing:
1) The number of video files, and their total combined size in KB.
2) The number of audio files, and their combined size in KB.
3) The number of image files, and their combined size in KB.
4) The number of document files, and their combined size in KB.
5) The number of files relating to user apps, and their total combined size in KB.
6) The number of system files, and their combined total size in KB.
In here, we define a video file to be any file that has file extension of avi, mov, .mp4, mkv, mpg, wmv, or mpeg.
Audio file is a file that has an extension of wav, mp3, wma or flac.
Image file is a file that has an extension of jpg, jpeg, png, bmp, gif or ico.
Document file is a file that has an extension of txt, doc, odt, or pdf.
A file is defined to be relating to user apps if the file is located within "*:\Program files*" directory structure, or within "*:\users\*\appdata\*\" except under its Microsoft folder.
A file is defined to be a system file, if it is located within "*:\Windows\", "*:\users\*\appdata\*\Microsoft\".
Do notice that the above definitions are exclusive and their priority is set by the number in the above list: That is, if a file is defined to be relating to user apps, it cannot be classified as any of the other types.
Or, if a file is classified as relating to system, it cannot be classified as any other type.
For example, a file C:\windows\temp\foo.jpg would be classified as a system file, not as image file and c:\program files (x86)\foobar\foo.mp3 is classified as an user app related file.
Furthermore, the output file must also contain data as to when each of the folder of the drive was last checked by the app and what was the folder's Last Modified stamp of that time.
If the app is run again, the folder's data is again checked only if 24 hours or more have passed since this folder's content was last analyzed by the app, OR if the folder's Last Modified stamp has changed.
In other words, if the content of the hard drive remains the same (i.e. no Last Modified stamp of any folder has changed), running the app the second time few minutes after the first run does not need to re-generate any of the data in the output file, instead the existing data remains as it does not need an update.
The app needs to run in Windows 7, 8, 10 and 11.
If the app fails to access some folder, it should continue and simply skip that data.