Re: SEEK: utility to add file date to name



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 EXIF
fields.
I want to rename the files to make the name include the file's
Modified Date as displayed in XP's file properties.
Well, then I wonder, what your question has to do with photography.

(If it makes it clearer, you could assume these files are not
image files.)
This 4 line Perl script will do that simple job nicely:

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.

.



Relevant Pages

  • Re: Booming or Fuming? Are You Alive? Or Are You Fading Away?!
    ... The single .cmd file which is a Command Library ... consists of ONLY scripting code using ONLY ... every detail of convoluted shell scripting command syntax. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Booming or Fuming? Are You Alive? Or Are You Fading Away?!
    ... The single .cmd file which is a Command Library ... consists of ONLY scripting code using ONLY ... every detail of convoluted shell scripting command syntax. ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Any other words like right and left, east and west?
    ... For this speech activated scripting stuff, ... program to Dragon NaturallySpeaking called "Dragonfly". ... programs that enables Continuous Command Recognition. ...
    (alt.usage.english)
  • Re: RegExp to find hex value 0D fails
    ... VBS does work on Vista but I cannot help you out with script issues on the Czech Vista. ... Are you scripting it in the Czech language? ... You need to repost this to the following newsgroup that works with vbscript in all MS Operating Systems ...
    (microsoft.public.windows.vista.general)
  • [COMMERCIAL] Ellié Computing Merge 2.1 for Linux
    ... You need to install the command line tools for that SCC. ... An ECMAScript compatible scripting engine is now included in ECMerge. ... Run on a differentiation, it will now export a textual ...
    (comp.os.linux.announce)