How do I rename existing files using a batch file for backup?

pkzip25 -add=all -dir=current -silent -locale -exclude=DistData.zip -exclude=extract.bat -exclude=run.bat -exclude=pkzip25.exe -exclude=extracted.txt -exclude=zipped.txt -exclude=.\STORE DistData.zip *.*
pkzip25 -view -directories DistData.zip >zipped.txt

copy DistData.zip ..\BKX\DistData_1.zip
cd ..\BKX
rename DistData_1.zip DistData_2.zip 
rename DistData_2.zip DistData_3.zip
rename DistData_3.zip DistData_4.zip
rename DistData_4.zip DistData_5.zip

      

+1


source to share


1 answer


rename DistData_1.zip DistData_2.zip 
rename DistData_2.zip DistData_3.zip
rename DistData_3.zip DistData_4.zip
rename DistData_4.zip DistData_5.zip

      

Wrong, you need to use the opposite order and remove the last one first:

del DistData_5.zip
rename DistData_4.zip DistData_5.zip
rename DistData_3.zip DistData_4.zip
rename DistData_2.zip DistData_3.zip
rename DistData_1.zip DistData_2.zip 

      

and maybe also move the DistData.zip file instead of copying, so it doesn't exist if you create a new zip file.

move DistData.zip ..\BKX\DistData_1.zip

      



But I don't know if this was your question / problem.

Edit: If you want to keep 5 zip files (instead of 4), I suggest this:

del DistData.zip >NUL 2>&1
pkzip25 -add=all -dir=current -silent -locale -exclude=DistData.zip -exclude=extract.bat -exclude=run.bat -exclude=pkzip25.exe -exclude=extracted.txt -exclude=zipped.txt -exclude=.\STORE DistData.zip *.*
pkzip25 -view -directories DistData.zip >zipped.txt

move DistData.zip ..\BKX
cd ..\BKX
del DistData_5.zip
rename DistData_4.zip DistData_5.zip
rename DistData_3.zip DistData_4.zip
rename DistData_2.zip DistData_3.zip
rename DistData_1.zip DistData_2.zip 
rename DistData.zip DistData_1.zip 

      

This way, you always have 5 backups.

+2


source







All Articles