pkzip using FOR loop

August 28, 2011 at 04:28:34
Specs: Windows 2003 std
Hi,
Hi,
I am using PKZIP on Windows 2003 server Standard edition.
I am using FOR loop to zip files to another location on the same server and deleting the original files. But the files are not getting zipped.
Below is the for loop:

cd /d %bkup_from%
for /r %bkup_from% %%i in (*.*) do (IF /i not "%%~xi" == ".zip" "C:\Program files\PKWARE\PKZIPC\pkzipc.exe" -lev=9 -add -excl=*.zip %bkup_to%\%%i.zip %%i && echo ZIPPED and REMOVED %%i && (del /q %%i))

The error I am getting is:

D:\BACKUP>for /R D:\BACKUP\ %i in (*.*) do (IF /I not "%~xi" == ".zip" "C:\Program files\PKWARE\PKZIPC\pkzipc.exe" -lev=9 -add -excl=*.zip C:\BACKUP\20110828-0630\%i.zip %i && echo ZIPPED and REMOVE
D %i && (del /q %i ) )

D:\BACKUP>(IF /I not ".DAT" == ".zip" "C:\Program files\PKWARE\PKZIPC\pkzipc.exe" -lev=9 -add -excl=*.zip C:\BACKUP\20110828-0630\D:\BACKUP\20110828-0630\EXTK.DAT.zip D:\BACKUP\20110828-0630\EXTK.DAT
&& echo ZIPPED and REMOVED D:\BACKUP\20110828-0630\EXTK.DAT && (del /q D:\BACKUP\20110828-0630\EXTK.DAT ) )


PKZIP: (E14) Can't create .ZIP file: C:/BACKUP/20110828-0630/D:/BACKUP/20110828-0630/EXTK.DAT.zip

**I think the issue is related to FOR loop, i is getting value of bkup_from variable also

Any help?
Thank you.


See More: pkzip using FOR loop

Report •


#1
September 1, 2011 at 08:11:14
Why are you using a FOR? Can't you just pass the %backup_from% to pkzip, and let it zip up everything?

How To Ask Questions The Smart Way


Report •

#2
September 2, 2011 at 04:03:58
Since there are 8-9 files to zip and as I want to keep each zip file separate, not in a single zip file, I used FOR loop.

Report •

#3
September 5, 2011 at 14:53:21
Fair enough.

Untested:

for /r %bkup_from% %%i in (*.*) do (IF /i not "%%~xi" == ".zip" "C:\Program files\PKWARE\PKZIPC\pkzipc.exe" -lev=9 -add -excl=*.zip %bkup_to%\%%~NXi.zip %%i && del /q %%i)

How To Ask Questions The Smart Way


Report •

Related Solutions


Ask Question