Solved CMD Batch newbie here...

Vmware Vmware workstation ( v. 8 ) - com...
May 15, 2012 at 12:51:56
Specs: windows xp sp2, xeon 2.3ghz 512MB RAM
Hey guys, why is this not working? The purpose is to automatically run a command using parameters from local filenames. The probkup line works fine is I echo it, but when I send the line to be run, the second iteration returns the name of the variable (!e:~0,8!) instead of the actual value (jl_00227). Where do I need to reset the variable so it catches the correct value on the consequent cycles?

@echo off
setlocal ENABLEDELAYEDEXPANSION

@cls
@c:
@cd \ccure800\4gl\database

@for /f %%e in ('dir /b jl_*.db') do (
SET e=%%e
probkup !e:~0,8! C:\ccure800\4gl\backups\bkp#00001_jlold_!e:~3,5!.bkp
pause
)

endlocal

=================================================

Returns this:

probkup jl_000227 C:\ccure800\4gl\backups\bkp#00001_jlold_00227.bkp
PROGRESS Version 9.1D07 as of Wed Sep 24 09:45:38 EDT 2003

4005 active blocks out of 4063 blocks in JL_00227 will be dumped. (6686)
0 bi blocks will be dumped. (6688)
The blocksize is 4096. (6994)
Backup requires an estimated 15.8 MBytes of media. (9285)
Restore would require an estimated 4005 db blocks using 15.6 MBytes of media. (
9286)
Backed up 4005 db blocks in 00:00:01
Wrote a total of 119 backup blocks using 15.8 MBytes of media. (9284)

Backup complete. (3740)
Press any key to continue . . .

C:\CCURE800\4GL\DATABASE>(
SET e=JL_00228.db
probkup !e:~0,8! C:\ccure800\4gl\backups\bkp#00001_jlold_!e:~3,5!.bkp
pause
)
PROGRESS Version 9.1D07 as of Wed Sep 24 09:45:38 EDT 2003
** Could not recognize argument: C:\ccure800\4gl\backups\bkp#00001_jlold_!e:~3.
(301)

!!! ERROR - Database backup utility FAILED !!! (8563)
Press any key to continue . . .

C:\CCURE800\4GL\DATABASE>(
SET e=JL_00229.db
probkup !e:~0,8! C:\ccure800\4gl\backups\bkp#00001_jlold_!e:~3,5!.bkp
pause
)
PROGRESS Version 9.1D07 as of Wed Sep 24 09:45:38 EDT 2003
** Could not recognize argument: C:\ccure800\4gl\backups\bkp#00001_jlold_!e:~3.
(301)

!!! ERROR - Database backup utility FAILED !!! (8563)
Press any key to continue . . .

C:\CCURE800\4GL\DATABASE>


See More: CMD Batch newbie here...

Report •


#1
May 15, 2012 at 23:21:26
What is probkup and what's the syntax?


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
May 16, 2012 at 05:30:49
PROBKUP is the backup utility for Progress databases.

SYNTAX:
probkup [fileset to take the backup from -- i.e. jl_000227] [location to store the backup -- i.e. C:\ccure800\4gl\backups\bkp#00001_jlold_00227.bkp]

I think you see my issue. The command uses the fileset name (jl_00227) without extension. In my application, we have predefined size databases and after certain amount of records, we close the database and open a new one. Previous database names use the prefix jlold. This is why I need to compute the journal volume fileset name first and then just the number to plave it in the bkp#00001_jlold_00227.bkp name.

After a long period of time, the database folder will contain hundreds of small prior journal databases and I am trying to write this script to automa the backup of all of them. Currently, I have to back those files one at a time.

Makes sense?


Report •

#3
May 16, 2012 at 07:29:46
✔ Best Answer
Never mind this post. Sorry for wasting your time. I was trying a simple task with a much more complicated process. Saving the filenames to a file and then parsing the file for the tokens worked a lot easier. See the new (much simpler) code:

@echo off

cls
c:
cd \ccure800\4gl\database

del files.txt
dir /b jl_*.db > files.txt

for /f "tokens=1,2,3 delims=_." %%a in (files.txt) do (
probkup %%a_%%b C:\ccure800\4gl\backups\bkp#00001_jlold_%%b.bkp
)


Report •
Related Solutions


Ask Question