How do I make the directories in a zip file relative to the target directory instead of my working directory
Solution 1:
As you note in the comments you now know how to change directory with your script, I'll explain the situation with zip regarding relative paths.
It is probably easiest to open terminal and cd
to kit123
; you have to make the target directory your working directory- you can't run the command from the base of your home directory or it will pick up all the paths of /home/$USER/..
If you use the -j
option, it will strip out all paths, as there isn't really an equivalent of the tar option --strip
with which different levels of path removal can be specified.
So please cd to your target directory (kit123
) and enter:
zip -r kit123.zip *
This will recursively (-r
) preserve all (*
) files and directories of files in the current directory (kit123
), and as relative paths (-p
) are preserved automatically unless the -j
option is present, the directory structure will be as you wished. Kit123
and subfolders (kitpart1
) with their own files will be present:
kit123
kitpart1
file.xcf
anotherfile.xcf
kitpart2
You can check the contents of the zip file with unzip -l zipfile.zip
.
For more information on the other options available for zip
, see man zip
and the Ubuntu manpage online.