I have a bit of an odd one that I can't seem to figure out.
Here's the setup. I am downloading a bunch of files given to a script via array. The files are not necessarily in the same folder, so I don't think just using cd to change directory and then add the files I want is going to work.
I have added -j to my shell command in order to not include the directories, and it worked... kinda. Now I have all the files in the top level of the zip, but it's also included the directories and duplicate versions of the files in the appropriate directories.
Edit: code added.
I have an array of files like this:
Other folder\Another subfolder\Why so many folders\
--Why so many folders
zip -jq zip array_of_files
zip zipname array_of_files -jq
You can use a combination of
zip together. Run the above command at the same level as the individual folders.
find . -type f -name "*.jpg" -print | zip -jq myfile.zip -@
The find command lists the
jpg files from he current path and with the
-@ option in
zip is to read from
stdin which the previous command produces. And the
-jq flag for junk paths.
With the above command, I was able to achieve the structure as you intended. Use
unzip -l to list the files under the archive without extraction.
$ unzip -l myfile.zip Archive: myfile.zip Length Date Time Name -------- ---- ---- ---- 0 11-26-16 13:08 image1.jpg 0 11-26-16 13:09 image2.jpg 0 11-26-16 13:09 image3.jpg 0 11-26-16 13:09 image4.jpg -------- ------- 0 4 files
The above simulation of mine is for your original input, when you had 4 images in total.