You are not logged in.
Pages: 1
Hi! How do I change the format of the date in a given filename?
For example:
IMPL Conf GLOB_Form_SCR-07001_02 Jan 2007_Rev.0
I want to have an output of:
IMPL Conf GLOB_Form_SCR-07001_2007-01-02_Rev.0
Using yyyy-mm-dd format.
Pls. help. Thanks!
Offline
If that date is file's last modified or created date, then it is easy. Using meta tags: :File_DateCreated: or :File_DateModified:, and the format can be defined from within the settings. But if you want to extract and parse the date from within filename, and then change it, this will be more difficult, and you'll need a script to do that.
Offline
Hi! thanks for the reply. I tried to use the metatags but it doesn't seem to work the way I like it to be. i tried using either DateModified and DateCreated but it still gives me an output of the current date. It should be date modified: 2007-01-02 instead of 2007-09-10.
Pls. help! thanks again!
Offline
If DateModified tag outputs the 2007-09-10 date, that means that the file was truly modified on that date. I guess you'll need to parse the original date from within the filename, and then reformat it. I can help you creating that script, but I will need to know all of the different variations of those dates within the filenames, and variations of their position within the filename, i.e. more examples.
For example, does the date always appear just before "_Rev.0"? Is it always in the same format, where month is represented by first 3 letters of the month?
Offline
One could solve this in an another way too:
This way it's no matter if the file date is still the same as in the file name.
For example:
IMPL Conf GLOB_Form_SCR-07001_02 Jan 2007_Rev.0
I want to have an output of:
IMPL Conf GLOB_Form_SCR-07001_2007-01-02_Rev.0
Search for
_
two digits => (\d\d)
an space => \s
three chars => (...)
space => \s
four digits => (\d\d\d\d)
_Rev
an dot => \.
one digit => (\d)
end of name => $
_(\d\d)\s(...)\s(\d\d\d\d)_Rev\.(\d)$
Replace with
_
the third group for back reference (the year) => $3
an minus => -
$2
-
$1
_Rev
.
$4
_$3-$2-$1_Rev.$4
----
Then search and replace the month abr.
Here i have used the translit function:
just create an text file in the "Translits" folder
like this months.txt
Jan=01
Feb=02
Mar=03
Apr=04
...
...
...
and add this translit as second rule.
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Nice work, Stefan
Offline
I hope it's okay to reactivate this old post but I'm new to the forum and I just found Renamer since I was googling for a date renaming solution and this forum post came up.
I applied the above search and replace but only the transliterate part seems to be working.
My file name is: zz- test may 19, 1954.txt
and I get this: zz- test 05.19, 1954.txt
(my transliterated dates slightly different - my format is "Jan " to "01.", to be precise).
How can I get the output to be in yyyy.mm.dd.ddd, so that the output file name would become:
zz- test 1954.05.19.txt?
Thanks!
Last edited by WmAMitchell (2011-05-19 17:47)
Offline
I hope it's okay to reactivate this old post but I'm new to the forum and I just found Renamer since I was googling for a date renaming solution and this forum post came up.
I applied the above search and replace but only the transliterate part seems to be working.
My file name is: zz- test may 19, 1954.txt
and I get this: zz- test 05.19, 1954.txt
(my transliterated dates slightly different - my format is "Jan " to "01.", to be precise).How can I get the output to be in yyyy.mm.dd.ddd, so that the output file name would become:
zz- test 1954.05.19.txt?
Thanks!
Hi WmAMitchell, welcome !
The regex above can not work because it is an pattern matching thing and must be adjusted exactly to your needs.
FROM:
zz- test 05.19, 1954.txt
TO:
zz- test 1954.05.19.txt
What is the delimiter to match the month? Always behind the second space?
And the year is always the last before the extension?
OK...
You have to:
1.)Match one-ore-more signs, an space, one-ore-more signs, an space ===> .+\s.+\s
Put that inside parentheses to be able to use the matched part as result by using $1 for the first (...)-group ==> (.+\s.+\s)
2.) Match two digits followed by an literal dot ===> (\d\d)\.
3.) Match two digits followed by an coma and an space ===> "(\d\d), "
4.) Match four digits ===> (\d{4})
5.) Use an reorder of this groups in the replacement:
$1 => "zz- test "
$4 => 1954
$2 => 05
$3 => 19
by adding needed spaces and dots your self.
DO:
Add an RegEx Rule:
1) RegEx: Replace expression "(.+\s.+\s)(\d\d)\.(\d\d), (\d{4})" with "$1$4.$2.$3" (skip extension)
You can test this very easy with ReNamer by pressing Shift+A and paste "zz- test 05.19, 1954.txt" into the Analyze window.
Then apply the rule and watch the output.
Please find more help in our wiki:
http://www.den4b.com/wiki/ReNamer:Rules:RegEx
or just ask if you have more questions (and please read my signature )
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Pages: 1