Page 1 of 1

Rename files with creation date

Posted: 14 Dec 2012 13:28
by chompy18
Hi,

I have a folder of images, all with the pattern of 4 alphanumeric characters, followed by 4 digits and the extension, for example:
abcd0234.jpg

I tried to select all files in the folder and use batch rename (shift-f2) with the pattern:
<datec yyyy.mm.dd-hh:mm>_<#001>_* /i
to get, for the example above:
2012.12.14-14:23_001_abcd0234.jpg

First, it does not work. There are conflicts. Can't understand why, since I am using a sequencer <#001>...
Second, this assumes I first sorted the files based on creation date, otherwise the sequencer will be wrong.

So, I am looking for a script that does just that - sort all the files in the folder based on creation date, and then rename the files according to the pattern above.

Can anyone help me with the script? I'm clueless with the scripting language.

Regards,
Chompy18

Re: Rename files with creation date

Posted: 14 Dec 2012 13:54
by highend

Code: Select all

sortby created, a; // Sort by "created", ascending
    sel f;
    rename b, '<datec yyyy.mm.dd-hh.mm>_<#001>_*', p;
Something like that?

Btw, you can't use hh:mm because ":" isn't allowed in filenames (windows).

Re: Rename files with creation date

Posted: 14 Dec 2012 14:08
by chompy18
highend wrote:

Code: Select all

sortby created, a; // Sort by "created", ascending
    sel f;
    rename b, '<datec yyyy.mm.dd-hh.mm>_<#001>_*', p;
Something like that?

Btw, you can't use hh:mm because ":" isn't allowed in filenames (windows).
Hey thanks highend!!!
That works perfectly! :)

BTW, you are right, ':' is not allowed, that is why the shift-f2 rename didn't work as well...

Thanks!

Re: Rename files with creation date

Posted: 24 Jun 2016 19:28
by largo
This works well for files, but can this be updated to rename folders as well as files? Folders also have a created date, and I'd like to use the created date to stamp the folders in the current directory as well.

Re: Rename files with creation date

Posted: 24 Jun 2016 19:35
by highend
Depends on how exactly the folders should be named. Short way:

Code: Select all

sortby created, a; // Sort by "created", ascending
    sel a;
    rename b, '<datec yyyy.mm.dd-hh.mm>_<#001>_*', p;
Long way (folders don't get an appended index):

Code: Select all

sortby created, a; // Sort by "created", ascending
    sel f;
    rename b, '<datec yyyy.mm.dd-hh.mm>_<#001>_*', p;
    sel i;
    rename b, '<datec yyyy.mm.dd-hh.mm>_*', p;

Re: Rename files with creation date

Posted: 25 Jun 2016 22:27
by largo
Thanks for your help. I did notice one folder had something screwy with the creation date, and using yyyy.mm in the rename rule, it put in '1899' for the year in the preview. But when I checked for the folder after the rename it had disappeared. Chalk that one up to a bug I suppose.