Thank you Peter.
Just as your email came in, I was Googling the syntax for the FOR command
and working out the DELIM option - I was having fun but developing a
headache.
Then you beat me to it !
But I did go on to try to understand the FOR command and I wanted to try
this to break up the NOW.exe output [Wed Nov 15 00:20:54 2006]
I've tested this and this also works.
________________________________________________________________
:: Use now.exe as date is not reliable (depends on timezone etc)
:: Let's split up its output and assign some variables
for /F "tokens=1-7 delims=: " %%i in ('now') do (
set DayofWeek=%%i
set Month=%%j
set Day=%%k
set Hour=%%l
set Min=%%m
set Sec=%%n
set Year=%%o)
:: OK so here's our directory name, let's make it!
set DirName=%BaseDir%\%Year%%Month%%Day%%Hour%%Min%%Sec%
if not exist %DirName% mkdir %DirName%
_______________________________________________________________
Is it true that using 2 delims (in this case ":" and " ") is bad ?
Also in the end, I did add the "seconds" back in...
Just in case someone managed to put a new card in and attempt to read inside
of a minute !
Also I changed the copy to Xcopy to read subdirectories
I havent done any scripting like this before, but its rewoken an old passion
for computers :-)
Final Version for your blessing Peter,
====================================================
:: CMD script for David Pan
:: Copyleft 2006 mobilecomputing.net.au
:: Dependency - now.exe available from MS resource kit
:: Let's keep our variables to ourselves
setlocal
:: Set your base directory here:
set BaseDir=D:\Photos
:: Set the drive letter of your device:
set Card=H:\
:: Use now.exe as date is not reliable (depends on timezone etc)
:: Let's split up its output and assign some variables
for /F "tokens=1-7 delims=: " %%i in ('now') do (
set DayofWeek=%%i
set Month=%%j
set Day=%%k
set Hour=%%l
set Min=%%m
set Sec=%%n
set Year=%%o)
:: OK so here's our directory name, let's make it!
set DirName=%BaseDir%\%Year%%Month%%Day%%Hour%%Min%%Sec%
if not exist %DirName% mkdir %DirName%
:: Copy (with verify and overwrite) our photos:
xcopy /S /V /Y %Card%*.* %DirName%
===========================================================
One final question please...
The FORMAT command doesnt seem to work from the Windows XP command line ?
David Pan
_______________________________________________
Gpcg_talk mailing list
[email protected]
http://ozdocit.org/cgi-bin/mailman/listinfo/gpcg_talk