marcelp1
Posts: 132
Joined: Mon Jun 11, 2012 8:41 pm

Zip - specifying source files directory

Fri May 17, 2013 8:30 am

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 :(

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Zip - specifying source files directory

Fri May 17, 2013 8:35 am

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/*
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

marcelp1
Posts: 132
Joined: Mon Jun 11, 2012 8:41 pm

Re: Zip - specifying source files directory

Fri May 17, 2013 8:47 am

Nope Same result :(

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Zip - specifying source files directory

Fri May 17, 2013 8:54 am

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 *

marcelp1
Posts: 132
Joined: Mon Jun 11, 2012 8:41 pm

Re: Zip - specifying source files directory

Fri May 17, 2013 8:59 am

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.

sprinkmeier
Posts: 410
Joined: Mon Feb 04, 2013 10:48 am
Contact: Website

Re: Zip - specifying source files directory

Fri May 17, 2013 10:32 am

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/

marcelp1
Posts: 132
Joined: Mon Jun 11, 2012 8:41 pm

Re: Zip - specifying source files directory

Fri May 17, 2013 10:55 am

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.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Zip - specifying source files directory

Fri May 17, 2013 10:58 am

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).
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

sprinkmeier
Posts: 410
Joined: Mon Feb 04, 2013 10:48 am
Contact: Website

Re: Zip - specifying source files directory

Fri May 17, 2013 11:28 am

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.

Return to “Beginners”