Polite request for help: Sorting files into subfolders by Date Taken/ Date Modif

Started by NewbieEve, January 20, 2023, 02:47:06 AM

Previous topic - Next topic

NewbieEve

Dear ExifTool users,

I have been looking everywhere for a software that I believe now I found in ExifTool, and may be a solution to my problem.
Additional issue is that unfortunately I have very little free time (mom with young kids) and I do not have the time to immerse myself in ExifTool. Hence my request for help in this post.
I have loads and loads of recovered files (on top of my regular files which are a lot as well and includes HEIC files that seem to be difficult to process for many programs) from trying to recover images from a failed hard disk (stupidly the only copy I had with pictures of a deceased loved one).

Would someone be able to help me make this script happen? (I will happily donate to the software if indeed it works).


Requirements:
-1 Moving files into subfolders (sorting)
-2 All items to be processed in subfolders (I believe they call this recursive?)
-3 If item with same name exist: rename one of the files (add copy number or something else) (No overwriting files!)
-4 Am I correct to deduce that videos do not have date taken like pictures do? (I don't see the information)
-5 Leaving the date modified/date created intact (since it is a move and not a copy)

I would like then to differentiatie between files WITH exif information on date taken, and those without:
---

For files with exif information for date taken:

Preferably this, sorted by the DATE TAKEN:
DT\ Filetype\ Year \ YearMonth \ YearMonthDay \ YearMonthDayCameramodelmake

I would be happy with anything that sorts the files into a date taken format though, or if that is one unique folder instead of subfolders...


For files without exif information for date taken

Preferably this, sorted by DATE MODIFIED:
DM\ Filetype \Year \ YearMonth \ YearMonthDay \ YearMonthDayCameramodelmake

Again..I would be happy with anything that sorts the files into a date modified format though, or if that is one unique folder instead of subfolders...



Alternatively I would also be fine if the command would be sorted into one folder with subfolders, as long as I can see which were sorted on date taken, and which were sorted on date modified.


Nice to have would be:
The same 2 subfolder systems for sorting, but for every file under 20 kb (so 2 folders for under 20 kb and 2 folders for equal or above 20 kb, 4 folders total). The reason for this is that there are a lot of damaged files that I can sieve out this way.


Would someone be able to help me with this? Or perhaps have an alternative suggestion?

Thank you in advance!

Eve

StarGeek

Quote from: NewbieEve on January 20, 2023, 02:47:06 AM-2 All items to be processed in subfolders (I believe they call this recursive?)

Yes.  With exiftool, this is accomplished by adding the -r (-recurse) option.

Quote-3 If item with same name exist: rename one of the files (add copy number or something else) (No overwriting files!)

Exiftool will not overwrite files.  If there is a name collision, then it will not copy the file unless the %c variable is part of the rename template.

Quote-4 Am I correct to deduce that videos do not have date taken like pictures do? (I don't see the information)

There's no such thing as a "Date Taken" metadata tag.  Programs that list a "Date Taken" will read data from multiple tags in order to fill out this property.

For jpegs, tiffs, and RAW file types, this is most commonly the EXIF:DateTimeOriginal tag, though Windows will read also read from four other tags, depending upon what exists in the file.  This is also different from the file system timestamps (FileCreateDate/FileModifyDate) which are usually displayed as "Created"/"Modified".

For videos, the most common is the Quicktime:CreateDate, which Windows will display as "Media created".  I'm not sure what Mac might use and display.  But there's a catch when it comes to videos.  The time stamp in videos are supposed to be set to UTC and the computer will adjust to the local time when displayed.  Both Windows and Mac do this properly, though some programs, most notably Adobe products, do not.

PNG files rarely have any metadata in them and very few programs actually read the metadata if it exists.

Quote-5 Leaving the date modified/date created intact (since it is a move and not a copy)

As long as no editing has taken place, then the file system time stamps are not touched.  If editing is done, then the -P (-preserve) option can be used to keep the modify date (FileModifyDate).


QuoteFor files with exif information for date taken:

Preferably this, sorted by the DATE TAKEN:
DT\ Filetype\ Year \ YearMonth \ YearMonthDay \ YearMonthDayCameramodelmake

You don't mention if you're on Windows or Mac/Linux.  Also, you don't mention how the top level directories are set.  I'm going to use C:/Pictures/ as a place holder for the destination, so you should change that to the actual path needed.  Note that for exiftool, while Windows uses backslashes \ as directory separators, slashes / also work and that is how exiftool will use them internally.

exiftool -api QuickTimeUTC -r -d "%Y/%Y%m/%Y%m%d/%Y%m%d" "-Filename<C:/Pictures/DM/$FileType/${FileModifyDate}{$Model;}${Make;}/%f%-c.%e" "-Filename<C:/Pictures/DT/$FileType/${CreateDate}{$Model;}${Make;}/%f%-c.%e" "-Filename<C:/Pictures/DT/$FileType/${DateTimeOriginal}{$Model;}${Make;}/%f%-c.%e" /path/to/files/

Break down.
The -api QuickTimeUTC option is used to adjust video file time stamps from UTC to local time.  It will have no affect on images.
The -r (-recurse) option will recurse into subdirectories.
The -d (-dateFormat) option reformats the date into the proper pattern. The meaning of the percent codes can be found under Common Date Format Codes.  The format string has the directory path built in.

The next part is the actual file moving/renaming.  It adds a copy number with a leading dash %-c only if there is a file name collision.  When you make multiple assignments to the same tag, in this case Filename, the latter assignment takes precedence if it is possible.  This means that exiftool will first try to use the DateTimeOriginal tag if it exists, then fall back to the CreateDate tag.  The result is that images will probably use the DateTimeOriginal but since that rarely occurs in videos, then videos will end up using the CreateDate.

For files that don't have either, it falls back to the different directory (C:/Pictures/DM/) and uses the FileModifyDate

Note that files that are missing either Make or Model will not be moved.  You can expand the command by adding a directory to move them to by placing it before the others.  Or you can add the -m (-ignoreMinorErrors) option and empty values will be used for those or the -f (-ForcePrint) option would use a hyphen -.

QuoteNice to have would be:
The same 2 subfolder systems for sorting, but for every file under 20 kb (so 2 folders for under 20 kb and 2 folders for equal or above 20 kb, 4 folders total). The reason for this is that there are a lot of damaged files that I can sieve out this way.

This is possible, but it would be more complex.  I'd suggest testing the above commands out first and then we can work on sorting out the sizes.

The above commands assume you're using Windows CMD.  If you're on Mac/Linux or using Windows PowerShell, change the double quotes " into single quotes '.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).