-2

So this is what I have so far. The problem I'm having is it archives the file to 7zip and when I try to tell it to move this file it says it's not there. I'm not sure if there's an easier way to move, zip, and rename a file and move it again to another folder.

@Echo Off
xcopy "\\READYSHARE\USB_Storage\Address Book\Address Book" "C:\Users\Service Department\Desktop\Zip" 
7za a –tzip "C:\Users\Service Department\Desktop\ZIpped" "C:\Users\Service Department\Desktop\Zip" /s /e
pause
tkocmathla
  • 901
  • 11
  • 24
  • Which line is your error occurring on? – aphoria Aug 15 '14 at 19:19
  • 7za a –tzip "C:\Users\Service Department\Desktop\ZIpped" "C:\Users\Service Department\Desktop\Zip" /s /e pause this creates a zip named ûtzip and when i run another batch file to rename it it says its not there so im wondering if theres a way to tell it name it while it zips ive tested the other batch file and it works to rename other stuff just not that file – Service Department Aug 15 '14 at 19:41
  • What are `/s` and `/e` supposed to do? 7zip uses hyphen-based arguments, not slash based. Also you are **already** telling 7za the filename while it zips... you've told it "C:\Users\Service Department\Desktop\ZIpped". – indiv Aug 15 '14 at 21:27

1 Answers1

0

It is always advisable to read the documentation of the commands to use before creating a batch file.

  • xcopy (Microsoft Windows XP documenation, easier to read) or xcopy (Microsoft TechNet article)
  • Documentation for 7-Zip standalone command line tool 7za is installed together with 7-Zip in program files folder of 7-Zip. The file to view is 7-zip.chm, a Windows help file.

The switches /s and /e belong to command xcopy, but are appended to call of 7za. /s is for copying also subdirectories, but not empty subdirectories. /e is for copying also subdirectories including empty subdirectories. It is possible to specify both, but usually just /e needs to be specified to copy a directory tree completely using xcopy.

To recursively archive all files and folders of a folder with 7za the switch -r must be used according to 7-Zip documentation.

@echo off
%SystemRoot%\System32\xcopy.exe "\\READYSHARE\USB_Storage\Address Book\Address Book" "%USERPROFILE%\Desktop\Zip" /E /I
"%ProgramFiles%\7-Zip\7za.exe" a –tzip "%USERPROFILE%\Desktop\Zipped.zip" -r "%USERPROFILE%\Desktop\Zip"
pause

I have not executed this batch file, but it should work if path to 7za.exe is correct on your computer.

Mofi
  • 46,139
  • 17
  • 80
  • 143