Page 1 of 1

[resolved]Rename filenames with modified date and update

Posted: 18 May 2013 20:36
by cren
hi,
there are 2 situations(very useful):
1."A.txt" to "A-M0difiedDate.txt";(i use: rename b , '*-<datem yyyymmdd>')
2.A renamed file was modified later , need "A-Olddate.txt" to "A-NewModifiedate.txt" (i use: rename r , '[0-9]{8} > <datem yyyymmdd>')

there are 2 problems:
1.in situation 2,some old files were named like "XXX130519.txt",not like"XXX-20130519.txt",how to deal with it too?
2.now i set 2 User-Defined Commands to deal with different situations, how can i accomplish with a single command?

thanks.,this will help me a lot!

-----------------------------------------------------------------
Ok guys, I have solved it.

Re: Rename filenames with modified date and update them

Posted: 19 May 2013 05:15
by cren
studied on regexp,problem 1 solved:
1.in situation 2,some old files were named like "XXX130519.txt",not like"XXX-20130519.txt",how to deal with it too?

Code: Select all

rename r , "[0-9]{6}|[0-9]{8} > <datem yyyymmdd>"
2.now i set 2 User-Defined Commands to deal with different situations, how can i accomplish with a single command?
working on it now...

Re: Rename filenames with modified date and update them

Posted: 24 May 2013 12:03
by cren
Done! It works well for me! :)

Code: Select all

IF(regexmatches("<curbase>","\d{4}((1[0-2])|(0\d))(([12]\d)|(3[01])|(0\d))") )
    {rename r ,"[-/._]?\d{4}((1[0-2])|(0\d))(([12]\d)|(3[01])|(0\d)) > -<datem yyyymmdd>";}
    //match on yyyymmdd
    
    elseif(regexmatches("<curbase>","\d{2}((1[0-2])|(0\d))(([12]\d)|(3[01])|(0\d))") )
    {rename r ,"[-/._]?\d{2}((1[0-2])|(0\d))(([12]\d)|(3[01])|(0\d)) > -<datem yyyymmdd>";}
    //match on yymmdd
  
  elseif(regexmatches("<curbase>","((1[0-2])|(0\d))(([12]\d)|(3[01])|(0\d))") )
    {rename r ,"[-/._]?((1[0-2])|(0\d))(([12]\d)|(3[01])|(0\d)) > -<datem yyyymmdd>";}
    //match on mmdd
  
  else
    {rename b ,'*-<datem yyyymmdd>';} 
    //just add date 
Load the script , set a shortcut ,and enjoy!