Sunday 29 December 2019

How to pass parameters in batch file and zip the file using 7z.exe?


I need to create a batch file as per below requirements


1) pass path1 & path2 while running the batch file


exl: testrun.bat E:\ERP\test1.txt E:\ERP\header.txt


2) Need to store these command line paths values in batch file


exl: var1=E:\ERP\test1.txt var2=E:\ERP\header.txt


3) zip the path1 using PKZIPW.exe or 7z.exe and create new o/p zip file


exl: 7z.exe u -tzip E:\Erp\Test1.zip var1


4) copy path2 in newly created o/p file


exl: copy /b var2+test1.zip E:\Erp\Final_output.zip



Answer



Try this:


@ECHO OFF

SET var1=%1
SET var2=%2

E:\Erp\7z.exe u -tzip E:\Erp\Test1.zip %var1%
copy /b %var2%\test1.zip E:\Erp\Final_output.zip

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...