Page 1 of 1

Zip - specifying source files directory

Posted: Fri May 17, 2013 8:30 am
by marcelp1
HI all,

from current dir so lets say /home/pi/
I want to zip the whole dir in /home/pi/share/FSD/20130516
into /var/www/
with the name FSD_20130516.zip

pi@RaspberryPi ~ $

Code: Select all

zip -rT /var/www/FSD_20130516 /home/pi/share/FSD/20130516
that would make the FSD_20130516.zip in the /var/www/ dir as I want it,
but the ZIP files included folders /home/pi/share/FSD/20130516 as well :(

Is there a way to specify source directory for the zip file?

man zip does not have the info :(

Re: Zip - specifying source files directory

Posted: Fri May 17, 2013 8:35 am
by SirLagz
Not at home at the moment so I'm just Guessin, but try this

Code: Select all

    zip -rT /var/www/FSD_20130516 /home/pi/share/FSD/20130516/*

Re: Zip - specifying source files directory

Posted: Fri May 17, 2013 8:47 am
by marcelp1
Nope Same result :(

Re: Zip - specifying source files directory

Posted: Fri May 17, 2013 8:54 am
by fbutler
marcelp1 wrote:Nope Same result :(
I haven't used zip in a long time, but have you tried?:

Code: Select all

cd /home/pi/share/FSD/20130516/
zip -rT /var/www/FSD_20130516 *

Re: Zip - specifying source files directory

Posted: Fri May 17, 2013 8:59 am
by marcelp1
fbutler wrote:
marcelp1 wrote:Nope Same result :(
I haven't used zip in a long time, but have you tried?:

Code: Select all

cd /home/pi/share/FSD/20130516/
zip -rT /var/www/FSD_20130516 *

Hi that works as well , thank you for that.

I have found what I needed. I should have read the man zip properly rather than looking for the key worlds (specify, source :(

-j
Store just the name of a saved file (junk the path), and do not store directory names. By default, zip will store the full path (relative to the current path).

so this one works now

Code: Select all

zip -rjT /var/www/FSD_20130516 /home/pi/share/FSD/20130516
lesson learned.

Re: Zip - specifying source files directory

Posted: Fri May 17, 2013 10:32 am
by sprinkmeier
zip doesn't know about unix file permissions.
Chances are that if/when you restore the files they'll all be marked executable, or group writeable or somesuch.

I recommend using tar:

Code: Select all

tar --create --gzip --file /var/www/FSD_20130516.tar.gz --directory /home/pi/share/FSD ./20130516
or

Code: Select all

tar --create --gzip --file /var/www/FSD_20130516.tar.gz --directory /home/pi/share/FSD/20130516 .
(the first one is more unix-y; un-taring the file puts everything in a subdirectory rather than polluting the current directory. neatness counts!)

If you need to read the files on a legacy PC get 7Zip
http://www.7-zip.org/

Re: Zip - specifying source files directory

Posted: Fri May 17, 2013 10:55 am
by marcelp1
sprinkmeier wrote:zip doesn't know about unix file permissions.
Chances are that if/when you restore the files they'll all be marked executable, or group writeable or somesuch.

I recommend using tar:

Code: Select all

tar --create --gzip --file /var/www/FSD_20130516.tar.gz --directory /home/pi/share/FSD ./20130516
or

Code: Select all

tar --create --gzip --file /var/www/FSD_20130516.tar.gz --directory /home/pi/share/FSD/20130516 .
(the first one is more unix-y; un-taring the file puts everything in a subdirectory rather than polluting the current directory. neatness counts!)

If you need to read the files on a legacy PC get 7Zip
http://www.7-zip.org/

Thank you for your reply, would user with Win XP Pro OS machine be able to open that file if he has no other compression/decompression software installed be default?

I went for the .zip as I know Windows can open .zip files ....and its just *.jpg files inside anyway.

Re: Zip - specifying source files directory

Posted: Fri May 17, 2013 10:58 am
by Joe Schmoe
I went for the .zip as I know Windows can open .zip files ....and its just *.jpg files inside anyway.
Yeah, I wouldn't worry about it. For what you are doing (where Windows compatibility is the issue, not arcane issues with Unix file permissions and such), ZIP is fine (and preferred).

Re: Zip - specifying source files directory

Posted: Fri May 17, 2013 11:28 am
by sprinkmeier
marcelp1 wrote: Thank you for your reply, would user with Win XP Pro OS machine be able to open that file if he has no other compression/decompression software installed be default?

I went for the .zip as I know Windows can open .zip files ....and its just *.jpg files inside anyway.
Probably not, Windows has a reputation for not playing well with others or sharing its toys :-)
(no hard feelings, us archane unix folk prefer our own toys anyway)

You could set up an FTP, WebDAV or Samba server on the RasPi, this should allow windows to browse /home/pi/share/FSD/20130516 and select files individually rather than having to zip and download the whole directory.