Changing Date Format for a Variety of Filenames

Advanced Renamer forum
#1 : 24/08-16 08:56
menace97
menace97
Posts: 9
Hi,

I was looking for some help to begin the daunting task of renaming all the files on my system that need a date in the filename. I have seen a few posts here about something similar, but nothing that really was quite what I was looking for.

To give you an example of what many of my filenames look like right now:

project abc - logo 13c 03-21-14 (mm-dd-yy)

I've come to realize over the years that I've been wanting to move to the ISO 8601 standard:
https://en.wikipedia.org/wiki/ISO_8601

that makes a lot of sense for making things standardized and easy to read and find later. Now I'm not sure if I want to put the date as a prefix or a suffix to every filename; I can see how a date prefix would make it very easy to sort by name (if the date information ever gets lost), but it looks slightly annoying and would probably rather just keep it at the end (as a suffix).

So since all filenames are different, but in my case I have the date at the end in most cases, is there anyone who can recommend a combination of methods to convert what I have in the above example to?:

project abc - logo 13c 2014-03-21 (yyyy-mm-dd)

Unfortunately using <date created> or <date modified> doesn't seem to be an option as they are not correct.

Thanks for any assistance, as this has been stressing me out trying to get it right - I'm not very experienced with AdvancedRenamer!

Sincerely,

menace97


24/08-16 08:56
#2 : 24/08-16 13:09
G. Lambany
G. Lambany
Posts: 187
Reply to #1:
Should be relatively easy with those two methods:

for dates 2000 to 2029:

method: Replace
Text to be replaced: (.+?)(\d\d)-(\d\d)-([0-2]\d)
Replace with: \120\4-\2-\3
Occurence: 1st
Case sensitive: Unchecked
Use regular expressions: Checked

for dates 1930 to 1999:

method: Replace
Text to be replaced: (.+?)(\d\d)-(\d\d)-([3-9]\d)
Replace with: \119\4-\2-\3
Occurence: 1st
Case sensitive: Unchecked
Use regular expressions: Checked

both the method can be enabled at the same time, they won't conflict

cheers


24/08-16 13:09
#3 : 03/09-16 12:42
menace97
menace97
Posts: 9
Reply to #2:

thanks very much for the assistance Rynos, i used both methods enabled at the same time, and tried them on some sample files to see how it would work - and unfortunately i didn't get any result at all. perhaps i input them in wrong, but i double-checked and still didn't see any changes.

i've included a screenshot of how it looked in AdvancedRenamer, what the output was after applying those two methods, and lastly, what exactly i'm looking for (ISO 8601 date standard added to the end of the filename).

thanks again for any help! :)

http://i.imgur.com/q3FXTeC.jpg


03/09-16 12:42
#4 : 03/09-16 17:40
G. Lambany
G. Lambany
Posts: 187
Reply to #3:
well, the regex were built to follow the format you provided, which was mm-dd-yy (with zeros for small numbers, in your examples), so that is why it is not working.

here is the new ones that will allow the month and day numbers to be of one or two digits:

method: Replace
Text to be replaced: (.+?)(\d{1,2})-(\d{1,2})-([0-2]\d)
Replace with: \120\4-\2-\3
Occurence: 1st
Case sensitive: Unchecked
Use regular expressions: Checked

method: Replace
Text to be replaced: (.+?)(\d{1,2})-(\d{1,2})-([3-9]\d)
Replace with: \119\4-\2-\3
Occurence: 1st
Case sensitive: Unchecked
Use regular expressions: Checked

should work now, let me know how it goes and provide more examples if it doesn't

cheers!


03/09-16 17:40
#5 : 12/09-16 07:35
menace97
menace97
Posts: 9
Reply to #4:

well it worked out a little bit better than before, but a few things didn't change. maybe it's just not possible. i just know that i have dates in the format of MM-dd-yy at the end, beginning and elsewhere at times, but i would like to be able to go through and put those dates in that MM-dd-yy format in a yyyy-MM-dd format and move them to the end of the filename. it seems really complicated, but i thought i would see if it might be possible.

here's the originals that i was testing to give some typical variety i've used over the years:

2-14-98 bookmarks - archive
2-21-98 bookmarks, switching to chrome - archive
document 1 8-2-12
document 2 8-13-12
vacation in spain - cycling tour 7-21-11
vacation in spain - restaurant on coast (marbella) 8-1-11

after using your new methods, here are the results i got:

2-14-98 bookmarks - archive
2-21-98 bookmarks, switching to chrome - archive
document 1 2012-8-2
document 2 2012-8-13
vacation in spain - cycling tour 2011-7-21
vacation in spain - restaurant on coast (marbella) 2011-8-1

- the first 2 examples didn't change unfortunately, as i would love for the dates to be converted to yyyy-MM-dd and moved to the very end of the filenames.
- the last 4 examples were so close, i'm just looking for a total of two digits for each MM and dd no matter what the number is (e.g. instead of 2011-8-1, for it to be 2011-08-01).

and here is what i was ultimately looking for:

bookmarks - archive 1998-02-14
bookmarks, switching to chrome - archive 1998-02-21
document 1 2012-08-02
document 2 2012-08-13
vacation in spain - cycling tour 2011-07-21
vacation in spain - restaurant on coast (marbella) 2011-08-01


thanks again so much, i know this probably is a bit too complicated to do with one 'preset' as a one-shot solution to renaming all my mismatched date-formatted names over the years - but i would love to finally get it right. any help is always much appreciated!

sincerely,
~menace97


12/09-16 07:35 - edited 12/09-16 07:37
#6 : 12/09-16 14:50
G. Lambany
G. Lambany
Posts: 187
Reply to #5:

with a script method, paste the following code (I used pastebin to make sure you get the right formatting too, code pasted here gets screwed):

http://pastebin.com/mBzBU1mU

not exactly pretty or efficient, but I think it should do what you want

cheers


12/09-16 14:50
#7 : 20/09-16 09:54
menace97
menace97
Posts: 9
Reply to #6:

Rynos,

That worked perfectly! Thank you so much for helping me through this dilemma, I was so concerned I was going to be renaming files well into the next year!

I am looking forward to test driving this with bulk renaming or batch renaming - this is absolutely fantastic!

Thank you very much! *bows*


~menace97


20/09-16 09:54
#8 : 21/09-16 20:40
G. Lambany
G. Lambany
Posts: 187
Reply to #7:
Glad it helped! ^_^


21/09-16 20:40
#9 : 26/09-16 13:19
menace97
menace97
Posts: 9
Reply to #8:

It really has been so helpful! The script looks so complicated to me I wouldn't have even known how to even start.

Just out of curiosity, a colleague sent me a number of files named with his particular 'style,' choosing to use and underscore instead of a dash.

e.g.

projects_9_23_16

Is it fairly easy to edit the wonderful script you created for me to accommodate differences like this should they crop up in the future?

To me it would looks easy enough, being that it is only a difference of a particular character, but I wouldn't be surprised if it was a lot more complicated than that, in which case, I will just manually rename files that don't follow the conventions of the samples I originally posted, to be:

projects 2016-09-23

If you happen to be by the forums and see this filename style deviation and might be able to suggest how to alter the script you provided to account for this, it would be much appreciated... but if it is a completely unique situation requiring a new script, then I will just be very happy with what you helped me out with, and manually rename the odd one here and there. I was just curious how different the script would be.

Thank you again so much!

Cheers! ~from one Canuck to another :)



26/09-16 13:19
#10 : 27/09-16 00:33
G. Lambany
G. Lambany
Posts: 187
Reply to #9:
revamped (a lot) code:
http://pastebin.com/ECh4figE

you can modify a few constants at the beginning of the script, and it should behave accordingly.

Will actually display "-regex error-" for a filename if the regex can't find the required string

just one regular expression this time

haven't tested it that much except for synthetic tests, so let me know if there is any bugs

cheers


27/09-16 00:33
#11 : 27/09-16 01:37
G. Lambany
G. Lambany
Posts: 187
Reply to #10:
it's missing a semicolumn ; at line 15.. doesn't prevent it to work, but should be added anyway

you can contact me a glambany@gmail.com

cya


27/09-16 01:37
#12 : 27/09-16 02:30
G. Lambany
G. Lambany
Posts: 187
Reply to #11:
Nevermind the error message, that sucked..

new version (that simply don't rename the file)

http://pastebin.com/97Yw5suU


27/09-16 02:30
#13 : 02/10-16 03:00
menace97
menace97
Posts: 9
Reply to #12:

I just grabbed your pastebin code and will be sure to check it out tonight Rynos. Thank you so much again! Cheers! I will let you know how it goes.

Take care.

:)


02/10-16 03:00