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 mac 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:  /users/<myname>/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: /users/<myname>/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?

Is this even possible!

Thanks,
TheDadCoderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gerwin Jansen, EE MVETopic Advisor Commented:
Hi, I'm probably not able to help you out but:

- Do the file names have date/time info in them as well or is just the timestamp basis for sorting?
- Which scripting language do you suggest experts use the solve your question?
0
TheDadCoderAuthor Commented:
Hi gerwinjansen, thanks for the response.

I'm not concerned about which scripting lang is used, the result is what i need :)

in terms of your first question, the filename itself can't be used it's just all random filenaming.   I was hoping the script would make use of the meta data of the file, i.e. the Created date.

Is this possible?
0
ozoCommented:
perl -MPOSIX -e 'for(<~/pictures/picstosort/*>){ $d=strftime "library/%Y %M %d",localtime((stat)[9]); ($f=$_)=~s/picstosort/$d/; rename $_,$f or warn "$_  $f  $!" }'
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

TheDadCoderAuthor Commented:
Hi ozo,

Does this search by meta data if the picture taken date? Or just the file?
0
ozoCommented:
It uses the time of last data modification timestamp.
Did you want to use something else?
0
TheDadCoderAuthor Commented:
Hi, reviewing a sample of the 100,000 image files that I have, some have an inaccurate date time for the modified date.

So these would need to use the camera's meta data instead. If no meta exists, then to use the last modified date.

Is that possible?
0
ozoCommented:
Do you have a script to extract the camera's meta data that my script can call?
0
ozoCommented:
Or do you have a specification of how the metadata is stored so I can write a routine to extract it?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Swift Programming

From novice to tech pro — start learning today.