Today I tried out creating a bat to automate a process I have to do all the time.
One problem I have is this code, where I try to create an achieve from a folder and all its subfolders and have it appear in the folder I ran the .bat from. (The same folder where the folder to be zipped is located.)
C:\Users\Ann>7za a -tzip Things.zip C:\"Users\Ann\Desktop\Stuff and things\things\"
Now this works just fine if I use cmd to run it (it creates the Things.zip in the Users directiory, where 7za.exe is located), but not in my .bat. Instead, when I run my .bat script it creates a 0 KB file called simply "7za" in the folder I ran the .bat from.
Can someone tell me why this is? I've read through most everything I could find on the topic and I'm not sure what I'm doing wrong here. Help would greatly be appreciated.
Your bat file shouldn't look like:
C:\Users\Ann>7za a -tzip Things.zip C:\"Users\Ann\Desktop\Stuff and things\things\"
You're redirecting output >
from trying to run c:\\users\\ann
to 7za a -tzip...
I expect the created file is something like 'ann' is not recognized as an internal or external command...
The bat file should just be:
@7za a -tzip Things.zip "C:\Users\Ann\Desktop\Stuff and things\things\"
If your bat file is in a different directory to c:\\users\\ann
then before the 7za line, run cd c:\\users\\ann
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.