Thank you so much Peter !
This definitely makes me go cross eyed trying to follow exactly whats going
on :-)

Ive tried running the batch and there are 2 problems.

The lines...

set DirName=%BaseDir%\%Year%%Month%%Day%%Time%
if not exist %DirName% mkdir %DirName%

give this error..

D:\>if not exist D:\Photos\2006Nov1422:47:36 mkdir
D:\Photos\2006Nov1422:47:36
The parameter is incorrect.

Does Windows accepts directory names with colons in them ?

Also, although the batch file doesnt quite get this far, is this line..

copy /V /Y %Card%* %BaseDir%

supposed to be..

copy /V /Y %Card%* %DirName%

?

Thanks so much once again.
This has been a great learning exercise.
Its going to take me a while to learn about that "for" command.

BTW - I agree about the danger of the automatic card format.
I think I might even move that to a completely separate batch file.

David Pan

=============================================
:: CMD script for David Pan
:: Copyleft 2006 mobilecomputing.net.au
:: Dependency - now.exe available from MS resource kit

:: Set your base directory here:
set BaseDir=c:\photos

:: Set the drive letter of your device:
set Card=f:\

:: 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-5 delims=/ " %%i in ('now') do (
set DayofWeek=%%i
set Month=%%j
set Day=%%k
set Time=%%l
set Year=%%m)

:: OK so here's our directory name, let's make it!
set DirName=%BaseDir%\%Year%%Month%%Day%%Time%
if not exist %DirName% mkdir %DirName%

:: Copy (with verify and overwrite) our photos:

copy /V /Y %Card%* %BaseDir%

:: Format the card:
format %Card%
================================================


----- Original Message ----- From: "Peter Machell" <[EMAIL PROTECTED]>
To: "General Practice Computing Group Talk" <[email protected]>
Sent: Tuesday, November 14, 2006 9:56 PM
Subject: Re: [GPCG_TALK] DOS scripting help or other ideas please


On 14/11/2006, at 6:30 PM, David Pan wrote:

Could someone show me how to write such a batch file please ?
Don't hate me, but it needs to run under Windows, not Linux.

A real problem that, scripting like everything is much simpler in the straight-forward, sense making operating systems. We are not just postering when we say that. I'm almost embarrassed to offer the script below, as I could easily do so much better with just a little shell. I find Cygwin to be a quick fix for situations like this but for the sake of the exercise I've stuck to what's available from MS.

This should do the trick for you. It's from memory so it may be a bit rough but you should be able to adapt it to work (hint = put 'pause' after suspect lines and execute it from a shell to debug). Adjust the variable BaseDir to where you want the parent of the date folders to be. Oh and you will get seconds on the end using this script, for free. If you want me to take them out I'll have to send you a bill.

There is a DOS command to deal with automatically mounting and unmounting volumes (mountvol) but at present it's so poorly implemented that I suggest you don't go there.

regards,
Peter.


:: CMD script for David Pan
:: Copyleft 2006 mobilecomputing.net.au
:: Dependency - now.exe available from MS resource kit

:: Set your base directory here:
set BaseDir=c:\photos

:: Set the drive letter of your device:
set Card=f:\

:: 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-5 delims=/ " %%i in ('now') do (
set DayofWeek=%%i
set Month=%%j
set Day=%%k
set Time=%%l
set Year=%%m)

:: OK so here's our directory name, let's make it!


:: Copy (with verify and overwrite) our photos:

copy /V /Y %Card%* %BaseDir%

:: Format the card:
format %Card%



_______________________________________________
Gpcg_talk mailing list
[email protected]
http://ozdocit.org/cgi-bin/mailman/listinfo/gpcg_talk



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.14.5/533 - Release Date: 13/11/2006



_______________________________________________
Gpcg_talk mailing list
[email protected]
http://ozdocit.org/cgi-bin/mailman/listinfo/gpcg_talk

Reply via email to