Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

zip folder without root folder info included

Writer Matthew Barrera

I have a zip.exe in my cmd shell. I would like to zip a folder in any subfolder, but don't want the folder to be zipped also.

Sample. I have the following situation:

c:/mainfolder/projectfolder/file.txt
c:/batch/zip.exe

The content of the resulting zip should be

projectfolder
projectfolder/file.txt

I would like to zip projectfolder, so the content of the zip file has only projectfolder with its file.txt. Mainfolder should not be visible. I also would like to do this as a oneliner.

My attempt did not work:

c:/batch/zip.exe -FSJr c:/mainfolder/projectfolder.zip c:/mainfolder/projectfolder

Any help ?

0

2 Answers

The folder will be zipped if it is specified, so the trick is not to specify it.

Do something similar to:

cd c:/mainfolder/
c:/batch/zip.exe -FSJr c:/mainfolder/projectfolder.zip *
1

UPDATE:

Change your current work directory to the source directory.
cd c:\mainfolder\
zip -FSJr c:/mainfolder/projectfolder.zip *

p.s.: You could copy zip.exe to c:\windows this way you don't need to specify the fullpath to zip cmd. the .exe extension is not neccessary to write.


Do not use the -r switch

-r Travel the directory structure recursively

Just use zip.exe -FSJ c:/mainfolder/projectfolder.zip c:/mainfolder/projectfolder.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy