Trying to change about 50,000 files at once (date transform)

Javascript renaming examples. Javascript renaming is supported in version 3 or newer.

Trying to change about 50,000 files at once (date transform)

Postby elyndar » Sat Mar 19, 2016 3:06 am

Hi,

I'm trying to figure out how to change a format of daymonthyear AA-### AA or daymonthyear AA-###-##.# AAA to AA-### AA Y_year M_month D_day. For example:

5JUL2001 FR-009 CAL > FR-009 CAL Y_2001 M_07 D_05
05JUN2013 FR-009-41.2 PM > FR-009-41.2 PM Y_2013 MON_06 D_05
01FEB2000 LQ-132 IMQ > LQ-132 IMQ Y_2000 M_02 D_01
01JUN2005 FR-009-41 IDX > FR-009-41 IDX Y_2005 M_06 D_01
1FEB2005 LBE-002-4 WO> LBE-002-4 WO Y_2005 M_02 D_01

I will eventually have a commercial licensed copy to do this with, but I'm trying to show proof that the program will do this to my boss so they will pay for the license. For now I have to use RegEx.
elyndar
 
Posts: 1
Joined: Sat Mar 19, 2016 2:47 am

Re: Trying to change about 50,000 files at once (date transform)

Postby Admin » Mon Mar 21, 2016 3:01 am

Hi, try this javascript function:

Code: Select all
n = name.indexOf(" ");
part1 = name.substr(0,n);
part2 = name.substr(n+1);
d = new Date();
d = Date.create(part1);
newName = part2 + ' ' + 'Y_' + d.getFullYear() + ' M_' + (d.getMonth()+1) + ' D_' + d.getDate();


You can preview the changes that would be applied even without a commercial license.

thanks
Admin
Site Admin
 
Posts: 1467
Joined: Tue Mar 08, 2005 8:39 pm


Return to Javascript Renaming