Script to sort files by creation date

Hi,

I have tons of family picture files in png/jpg format that I want to sort. Using a script on the PC I want the script to traverse a given directory structure and moving all files into another path which is a flat directory with only folders with newly moved files, in the folder format name of YYYY MM DD

Source folder: C:\pictures\picstosort
(This is a folder full of other folders and pics in the root of this folder that needs to be traversed fully)

Destination folder: C:\pictures\library
(Folders in here are in the format YYYY MM DD)

Can anyone write this script for me, i don't have a clue how to do this?

Who is Participating?

That was the point of getting some sample information from exiftool ...
As before, in test mode (lines 32 and 33); this version creates a log file in csv format (which is overwritten with each new run).

Try this batch script; save as Whatever.cmd. It is currently in test mode and will only print the commands it would normally run, without really doing anything, so that yo can test it.
To run it for real, remove the two uppercase ECHOs in lines 14 and 15.
It currently assumes that you have a date format of YYYY/MM/DD; if not, please post the first line of the script's output (where it shows the file date of the files being processed).

You may find the easiest thing to do is to do a Search for *.jpg (using the Details view), and then you can move the files to suit yourself. Flicking to the thumbnails view can often let you know what you're looking at.

I personally name my photo folders in a REVERSE date format, followed by some explanation ie:
2012-08-31 - Dad's birthday weekend

I don't bother splitting events into individual days, as that often isn't relevant to me. Naming the dates in reverse order lets them sort more easily.

It's keeping the time of the day, can we omit this and use the YYYY-MM-DD folder format?

Thanks so much

0

TheDadCoderAuthor Commented: 2013-10-19

Hi DanDh99 - I have upward of 100,000 images, mostly already sorted into YYYY/Month folders, but it's a mess that needs a lot of work. As i sort more pictures into the library, I find pictures out of place, in the wrong month and even year folder... so i must have been drunk when i put them in there in the first place!

So I'm looking at a script to just rework the whole folder structure into days, and then I'll move into months and years.

so i end up with :

root:
YYYY

root+1
Months of the year

root+3
Days of the Month

i.e.
2013/October/19

or as it seems the case will be
2013/October/2013-October-19

If i only had a few images, then find a manual approach like i have been doing is fine (15+ years). But with image sizes increasing and number of images taken it's getting out of control and need a reliable and consistent method.

Thanks for the input though. (I'm sure I will manually suffix many names to the final level day folder for events, as you mentioned.)

Probably yes (though the process might take significantly longer). What you're looking for is a part of the meta data of the file(s) (that may or may not exist, depending on the application/camera that created the picture).
Download ExifTool from http://www.sno.phy.queensu.ca/~phil/exiftool/
Unpack the archive (contains a file "exiftool(-k).exe"), and rename the exe to "exiftool.exe"; put this into the script folder.
Then open a command prompt, entercd /d "Y:\our\script\folder"
Now enterexiftool.exe -*date* -s1 "P:\ath\to\the\screenshot\picture\050112 139.jpg"
(or stop after "-s1 " and drag the file from Explorer into the command prompt to save some typing), and post the output here.

0

TheDadCoderAuthor Commented: 2013-10-21

Hi oBda, thanks for that. Here's the output of that same file from the screenshot:

Test file 2
I also performed the same process on another random file, but before I did I checked to see if there was a 'DateTaken' value in windows explorer, as per screenshot. This file did not, and the output from exiftool is different, missing the createdate variable:

Hi oBda - I've processed through a test group of 12,000 jpg files and the majority work fine, as expected.

However, I notice two things.

1. program works only with jpg, that's no problem I can make another version for png. infact this is a nice benefit as it allows me to review none-jpg picture files and investigate those separately.

2. I apparently had a camera back in circa 2004-2006 which didn't record any date/time, except from 1/1/2004 00:00, i.e. clock starts ticking after batteries go in, etc. so not RTC built in. So I have found images that were taken in 2006 and are being filed as 2004. This is not something the script can help with as the file datestamp is wrong and the meta data is wrong. Just a note to be aware of i guess.

Sorry, should have mentioned that: the script should be able to process .png as well, just add it to to the FileMask variable in line 5 (multiple patterns are possible):set FileMask=*.jpg *.png
Or simply use *.* if you know that there are only pictures in the folders anyway.

I've been watching from the sidelines and knew that you would get excellent suggestions. I too have used the exiftool.exe program for a variety of things. I'm just wondering about the images that had the wrong date written to the EXIF data by the cameras.

I remember seeing a couple of command line switches or inbuilt variables that can be used with the actual program command to correct wrong dates, rather than modifying the date from the batch file using some jiggery pokery. I'm sure it was exiftool.exe that had these additional options, but I have used quite a lot of command line image-related programs. Perhaps it wasn't the date that was "fixable", but rather to offset the wrong hour when entering or leaving daylight saving time and the camera doesn't update this automatically.

If you are interested in trying to fix the dates, presuming you know the year the photos were taken, then I am sure this is something that is easily achievable. Exiftool, and a number of other command line image handling programs, can modify EXIF data. Perhaps a new question would be more appropriate than posting here in a closed question.