Re: SEEK: utility to add file date to name
- From: "J. Clarke" <jclarke.usenet@xxxxxxx>
- Date: Thu, 5 Mar 2009 09:56:19 -0500
Ofnuts wrote:
Justin C wrote:In article <pg2tq4hgkql48663a2np2jvvqmdp6qqqnc@xxxxxxx>, Jürgen
Exner wrote:
jasper <jasperdoesnotwantmail@xxxxxxxxxxx> wrote:Exiftool? My image files do not contain any data in the EXIFWell, then I wonder, what your question has to do with photography.
fields.
I want to rename the files to make the name include the file's
Modified Date as displayed in XP's file properties.
(If it makes it clearer, you could assume these files are notThis 4 line Perl script will do that simple job nicely:
image files.)
for (@ARGV){
my ($day, $month, $year) = (localtime((stat($_))[9]))[3..5];
$year += 1900; $month += 1;
rename $_, "$year-$month-$day-$_";
}
I was going to suggest Perl, but that there would a steep learning
curve... but you went one, or several better and provide a solution.
Nice.
Had to refer to docs to fully understand it though. Impenetrable, but
elegant in it's brevity.
Justin.
There is surely a way with plain Windows shell commands (because in a
"for" loop, you can use "%~tF" to obtain the date/time string of the
file in a %F(*). However, using it to _insert_ a readable date/time in
the file name isn't going to be pretty, certainly much less readable
than its Perl equivalent. There could also be a way with \/15u4|8451(.
(*) for instance,try:
for %F in (*.*) do @echo %F is dated %~tF
Just a comment but Windows has more powerful tools than the command or cmd shells available.
2K and later have Windows Scripting Host that runs vbscript and jscript code from the command line--with older versions of windows you have to invoke it with cscript (i.e. cscript helloworld.vbs) but in Vista you can just type "helloworld" on the command line and if helloworld.vbs is anywhere in your search path it will run.
If you search the Microsoft site on "Windows script" you'll find quite a lot of information.
When Vista shipped they added another capability, the Powershell, which is downloadable for Vista and XP--that's a full Unix-style shell with complete scripting capability, but it is not exactly a clone of any of the Unix shells--Microsoft as usual went off in their own direction.
For someone versed in vbscript, jscript, or Powershell scripting such an application should be easy to toss off.
All that said, since there are decent purpose-made applications for that particular task that can be obtained free or at nominal cost there's no real point to writing a script, but I thought I would mention this.
.
- References:
- Re: SEEK: utility to add file date to name
- From: Ofnuts
- Re: SEEK: utility to add file date to name
- Prev by Date: How far is "infinity?" - Not a metaphysical query
- Next by Date: Re: ViewNX - Adnormal Terminations?
- Previous by thread: Re: SEEK: utility to add file date to name
- Next by thread: Beware Entac Direct UK
- Index(es):
Relevant Pages
|