If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Rate Thread | Display Modes |
#31
|
|||
|
|||
cmd files
On Thu, 2 Dec 2010 09:43:34 -0600, Dond13 wrote:
OK, I've been getting so many helpful comments that I am probably getting confused. I am taking the suggestion of the "CHOICE" command and using it. It seems to work up to a point, and that is when I substitute "%drive%" for the drive address, it inserts nothing. I receive an error that I can't make a 'cyclic' copy. I am showing a shortened version of my original cmd file with the suggested fixes. Can you look it over and see where I am going wrong please? Thanks Don D. CHOICE /C LGDID /N /m "Backup to drive l:, G:, I: D:, (or N for None)?" IF ERRORLEVEL 1 SET DRIVE = L: IF ERRORLEVEL 2 SET DRIVE = G: IF ERRORLEVEL 3 SET DRIVE = I: IF ERRORLEVEL 4 SET DRIVE = D: IF ERRORLEVEL 5 ( ECHO nO BACKUP DRIVE CHOSEN ECHO PAUSE rem GOTO EXIT ) ECHO Backing up to %DRIVE% echo/ CHOICE /C YN /N /m "OK to proceed? Y or N?" IF ERRORLEVEL 2 ( pause GOTO exit) ECHO xcopy c:\excel\*.* %DRIVE%\excel\ /v /y /s /d if errorlevel 1 goto error xcopy c:\quattro\*.* %DRIVE%\quattro\ /v /y /s /d if errorlevel 1 goto error goto exit :error echo There was an error writing to the disk. echo The disk may be full or it may not be echo formatted. Check and try again. echo. pause :exit pause You would get that behavior if drive didn't get set, since in that case the xcopy command would be interpreted as: xcopy c:\excel\*.* \excel\ /v /y /s /d Put a command echo Selected drive is %drive% ahead of the copy commands and see what you get. Also in your choice command you wrote LGDID instead of LGDIN. I have no idea what that would do. I'll leave the testing up to you - but do the echo before you make that change, just to see what is happening - that makes for a better experiment :-) -- Gene E. Bloch (Stumbling Bloch) |
Ads |
#32
|
|||
|
|||
cmd files
"Gene E. Bloch" wrote in message .. . The only bad thing is that I almost never use scripts (bat, cmd) these days, so now I have knowledge that all I can do with is brag about it :-) Maybe I'll do that at lunch later today... They are still a regular part of my life both at home and work so I tend to keep up with the basics - I won't pretend to be anything more than a casual batch scripter, intermediate level at best. I always thought I was pretty good at it, but I've since learned where I really am on the scale - if you've seen what the regulars over in alt.msdos.batch and alt.msdos.batch.nt are capable of you'd understand where I'm coming from... -- Zaphod Voted "Worst Dressed Sentient Being in the Known Universe" for seven years in a row. |
#33
|
|||
|
|||
cmd files
On Thu, 02 Dec 2010 12:11:28 +0000, Ed Cryer wrote:
A blank REM is good for layout spacing. A double colon is even better. RegCleaner is one of my all-time favourite You're entitled to your opinion. -- Stan Brown, Oak Road Systems, Tompkins County, New York, USA http://OakRoadSystems.com Shikata ga nai... |
#34
|
|||
|
|||
cmd files
On Thu, 2 Dec 2010 16:09:50 -0500, Zaphod Beeblebrox wrote:
"Gene E. Bloch" wrote in message .. . The only bad thing is that I almost never use scripts (bat, cmd) these days, so now I have knowledge that all I can do with is brag about it :-) Maybe I'll do that at lunch later today... They are still a regular part of my life both at home and work so I tend to keep up with the basics - I won't pretend to be anything more than a casual batch scripter, intermediate level at best. I always thought I was pretty good at it, but I've since learned where I really am on the scale - if you've seen what the regulars over in alt.msdos.batch and alt.msdos.batch.nt are capable of you'd understand where I'm coming from... Maybe I'll look there, but right now I'm not ready to embarrass myself :-) And I forgot to say thanks for this: A bit of research reveals that when called from a .CMD, 'set' resets errorlevel, but when called from a .BAT, it does not. Not sure what the reasoning is behind the behavior, but it is consistent back to XP at least .... from an earlier post by you. It's very credible, but testing it could be hard. It is possible that echo %errorlevel% would return a new errorlevel. Yeahbut...One could first save the value by: set tempval %errorlevel% with no loss of generality (I haven't said *that* for a long time!). -- Gene E. Bloch (Stumbling Bloch) |
#35
|
|||
|
|||
cmd files
"Stan Brown" wrote in message t... On Thu, 02 Dec 2010 12:11:28 +0000, Ed Cryer wrote: A blank REM is good for layout spacing. A double colon is even better. Except that using a broken label (double colon) as comment starter in a loop or other parenthetical structure will break it. For example: IF EXIST C:\autoexec.bat ( :: ECHO Do something :: ) results in the error message: ) was unexpected at this time. But if you replace them with REM statements, it works fine. You run into similar problems in FOR loops. -- Zaphod Pan-Galactic Gargle Blaster: A cocktail based on Janx Spirit. The effect of one is like having your brain smashed out by a slice of lemon wrapped round a large gold brick. |
#36
|
|||
|
|||
cmd files
On Mon, 29 Nov 2010 20:12:01 -0000, Sunny Bard
wrote: Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . If you call the .cmd file from a shortcut, or from a cmd.exe window,, you can pass the F: G: or H: argument on the command line, then within the .cmd file replace your hard coded drive letter with %1 keep your backup command on the pendrive - then you *have* to find the drive letter! e.g. savefile.cmd is copy c:\users\mystuff\*.* \mystuffbu\ etc -- "Nuns! NUNS! Reverse! Reverse!" |
#37
|
|||
|
|||
cmd files
On Fri, 3 Dec 2010 08:26:05 -0500, Zaphod Beeblebrox wrote:
"Stan Brown" wrote in message t... On Thu, 02 Dec 2010 12:11:28 +0000, Ed Cryer wrote: A blank REM is good for layout spacing. A double colon is even better. Except that using a broken label (double colon) as comment starter in a loop or other parenthetical structure will break it. For example: IF EXIST C:\autoexec.bat ( :: ECHO Do something :: ) results in the error message: ) was unexpected at this time. But if you replace them with REM statements, it works fine. You run into similar problems in FOR loops. Thanks -- I haven't actually written a batch file in native command prompt since before the ( ... ) construct was added; I've been using 4NT and then TCCLE. So I appreciate the correction. -- Stan Brown, Oak Road Systems, Tompkins County, New York, USA http://OakRoadSystems.com Shikata ga nai... |
Thread Tools | |
Display Modes | Rate This Thread |
|
|