Return to date issues ... renamer with intelligence that can convert yyyy.mm.dd to yyyy.mm.dd.ddd?

39 views
Skip to first unread message

Wm.M

unread,
Aug 27, 2013, 10:04:56 AM8/27/13
to re...@googlegroups.com
Hi, everyone!  Thanks for all the help months and months ago (years?) re regexp that I used in RenameIt!  Since then, my constant renaming dates needs have been pretty much covered.  Really appreciate it.

But I have been left to come back and always add the day of the week.

This is not quite OT as it is related perhaps, but this seems to be to be the best group to ask if there is any freeware out there than can be used to add days of the week to the dates?  I've always felt this was a bit beyond regular regexp that something more would have to be in the software to calculate dates, but, what the heck:  don't know if I don't ask if there is such an app ... <g>

So, in a folder of files, wherever there is something like this:

Filename- 1954.04.10.- ... .mp3
Filename- 1948.11.24.- ... .mp3
Filename- 1948.11.25.- ... .mp3
Filename- 1942.06.09.- ... .mp3

Would be turned into this, adding the day of the week:

Filename- 1954.04.10.Sat- ... .mp3
Filename- 1948.11.24.Wed- ... .mp3
Filename- 1948.11.25.Thu- ... .mp3
Filename- 1942.06.09.Tue- ... .mp3

This is a good example of one of the uses of massive file renaming that I use a couple of renamers for that support regexp, but I also do a lot of saving of documents that have dates that are easily converted to yyyy.mm.dd but that never show the day of the week which I must rename but THAT ARE ALSO AFTER YEAR 2000 (i.e., tons of banking files/statements, etc.)

Is there any way to automate adding the day of the week?  I still spend too much time manually renaming because I have to go back and add this info by hand to each file name.  Granted, I use Oscar's Renamer for that which supports macros and it's a breeze since it's like typing into a text editor (literally, you rename via a text editor-like interface) but it still takes too long.

Thank you in advance!

Cheers,

Ross Presser

unread,
Aug 27, 2013, 4:01:04 PM8/27/13
to re...@googlegroups.com
In .NET, the "something more" can be put into a function that gets called for each match:

Sub Main()
dim files() as string = { "Filename- 1954.04.10.- ... .mp3","Filename- 1948.11.24.- ... .mp3","Filename- 1948.11.25.- ... .mp3","Filename- 1942.06.09.- ... .mp3" }
for each f in files
System.Io.File.Rename(f, RenameFile(f))
next
End Sub
   Function RenameFile(inputFile As String) As String
       Dim re = New System.Text.RegularExpressions.Regex("(\d\d\d\d)\.(\d\d)\.(\d\d)\.")
       Return re.Replace(inputFile, AddressOf getReplacement)
   End Function
   Function getReplacement(m As System.Text.RegularExpressions.Match) As String
       Dim yyyy = CInt(m.Groups(1).Value)
       Dim mm = CInt(m.Groups(2).Value)
       Dim dd = CInt(m.Groups(3).Value)
       Dim theDate = New Date(yyyy, mm, dd)
       Return theDate.ToString("yyyy.mm.dd.ddd")
   End Function
Reply all
Reply to author
Forward
0 new messages