Rename files with creation date

Discuss and share scripts and script files...
Post Reply
chompy18
Posts: 2
Joined: 14 Dec 2012 13:05

Rename files with creation date

Post 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

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Rename files with creation date

Post 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).
One of my scripts helped you out? Please donate via Paypal

chompy18
Posts: 2
Joined: 14 Dec 2012 13:05

Re: Rename files with creation date

Post 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!

largo
Posts: 2
Joined: 24 Jun 2016 19:22

Re: Rename files with creation date

Post 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.

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Rename files with creation date

Post 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;
One of my scripts helped you out? Please donate via Paypal

largo
Posts: 2
Joined: 24 Jun 2016 19:22

Re: Rename files with creation date

Post 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.

Post Reply