Using ZIP in command line

Hi I try to using the application ZIP by command line (for a futur planning), I can zip but when create a zip with all path it create all the path in the zipfile I don’t want it…

Example with this command:
zip -r -9 -J main.c /boot/home/TestLove/*

that create a /boot/home/TestLove/ directory in the zip itself and I don’t want it I just want the main.c here is just an example. I want make it possible to zip an entire directory also.

Thanks

Install my zipGUI from our repo and look into the source at /boot/system/apps/zipgui

1 Like

That seem a compiled application cause Yab draw special caracters when I open this file.

hi Kitsune64,

if i understand right, i think you are on the rigth way.

change in your example the option from upper J to lower j. I think that is what you want.

your example.
zip -r -9 -J main.c /boot/home/TestLove/*

my example
zip -r -9 -j main.c /boot/home/TestLove/*

1 Like

Hi thanks the -j option erase all the subdirectory in the archive that’s near but I want in my case

if I have a directory like this into:

main.c
/pictures/picture.png

I want it like the previous hierarchy in the zip file and not to have this:
/boot/home/Test/picture/picture.png
/boot/home/Test/main.c

-j erase the directory picture and do
main.c
picture.png

I must maybe go to the directory as a root directory but chroot command don’t work like I want here
I have try chroot /boot/home/Test/ zip but it say no suck file or directory about “zip”

Ok I will try with the cd command maybe that will work

Yes i use a c program to start my Apps. Zipgui.yab should be in the same directory.

If not i can look at home.

Ok I have find the solution with the cd command
As example:

cd /boot/home/Test && zip -r -9 -J main.zip *

1 Like

Here a screen of options in zipGUI

https://old.besly.de/menu/search/archiv/sys/zip-gui_eng.html

1 Like

It looks like your problem partially arises from the zip command always using the second non-switch argument as the path to zip up. So your first example asks it to make a file called ‘main.c’ and zip the -path- ‘/boot/home/TestLove’ and all the files in the last directory.

Are you expecting the command to zip files from anywhere as though you were inside the directory you want to zip up? Because that seems a little counterintuitive based on the described behavior. Since I haven’t used that command in Haiku, I’m curious as to what happens if you do this:

zip -r -9 -J /boot/home/Test/main.zip *

or

zip -9 -J /boot/home/Test/main.zip *

If it’s just exactly the same as Unix/Linux zip then you may want to review the help file and double check that you’re using the command correctly (for the desired outcome). Specifying ‘-r’ for recursive travel through the path is likely what was causing it to re-create the /boot/home/TestLove/ path inside the zip file.

P.S.

1 Like

The first line worked for me.
I have solve it by an other way with cd but you command line work too.

The second line remove subdirs files.

Thanks

No. Using an absolute path in the command line was causing it to write the absolute path into the zip file.