[resolved]Rename filenames with modified date and update

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
cren
Posts: 6
Joined: 18 May 2013 20:02

[resolved]Rename filenames with modified date and update

Post 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.
Last edited by cren on 24 May 2013 12:09, edited 1 time in total.

cren
Posts: 6
Joined: 18 May 2013 20:02

Re: Rename filenames with modified date and update them

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

cren
Posts: 6
Joined: 18 May 2013 20:02

Re: Rename filenames with modified date and update them

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

Post Reply