2

how to zip and copy files which has been created on a daily basis in a batch file (windows). I am trying on this from long time but bad luck am unable to find the exact solution for this. I am not proficient with scripting or programing. Kindly Help me to resolve, and thanks in advance to everyone. For more clarification hereby I am telling the scenario.

I have configured for creating backups automatically for our application which runs on Windows server 2012. Backups are creating on a daily basis with filename like applicationbackup_01_01_2015_000001_111111 so I need to zip this back up and need to copy to other location.

Primarily I am got stucked in zipping the files problem. Kindly help me.

Satheesh

  • I'd recommend a third-party tool if at all possible, like WinRAR or 7-Zip. If your security policy prevents software from being installed, see [this question](http://stackoverflow.com/questions/30211/can-windows-built-in-zip-compression-be-scripted) for how to natively create archives. – SomethingDark Feb 23 '15 at 10:40
  • How to do the same with 7Zip or WinRAR? can you provide me a link or pgm using this? because am not proficient in pgming. @SomethingDark – Satheesh Rajan Feb 23 '15 at 11:12
  • http://superuser.com/questions/63807/commandline-to-zip-a-file-using-winrar – SomethingDark Feb 23 '15 at 12:26

1 Answers1

0

Check this question and this script

And after you have the zipjs.bat you can use:

for %%a in (applicationbackup_*) do (
   call zipjs.bat zipItem -source "%%~fa" -destination "%%~na.zip"
   copy "%%~na.zip" c:\somewhere
)

I assume you know how to filter only files you want by the date.

Community
  • 1
  • 1
npocmaka
  • 55,367
  • 18
  • 148
  • 187