Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Utility to zip many files into separate archives?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
eddo
n00b
n00b


Joined: 03 Mar 2008
Posts: 51

PostPosted: Sun Jan 04, 2009 10:46 am    Post subject: Utility to zip many files into separate archives? Reply with quote

As above really, I have a whole directory of files which I need in individual zip files. zip doesn't seem to have this feature as standard and find -exec won't work because you can only use the filename once, where as zip takes two arguments "zip archivename filetobezipped", so any ideas? Thanks in advance.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3940
Location: Hamburg

PostPosted: Sun Jan 04, 2009 11:32 am    Post subject: Reply with quote

Code:
find . -type f -print0 | xargs -0 -I{} -n 1 echo zip {}.zip {}
Use that command w/o echo to do it really.
Back to top
View user's profile Send private message
eddo
n00b
n00b


Joined: 03 Mar 2008
Posts: 51

PostPosted: Sun Jan 04, 2009 12:08 pm    Post subject: Reply with quote

Thanks a lot, but I don't suppose there's a way of doing it so it removes the file extention for the archive name? E.g. example.exe -> example.zip not example.exe.zip? Many thanks.
Back to top
View user's profile Send private message
eddo
n00b
n00b


Joined: 03 Mar 2008
Posts: 51

PostPosted: Sun Jan 04, 2009 1:03 pm    Post subject: Reply with quote

No worries, I just used

for file in *.exe.zip ; do mv $file `echo $file | sed 's/\(.*\.\)exe.zip/\1zip/'` ; done

Cheers,
Back to top
View user's profile Send private message
yngwin
Retired Dev
Retired Dev


Joined: 19 Dec 2002
Posts: 4572
Location: Suzhou, China

PostPosted: Mon Jan 05, 2009 1:01 am    Post subject: Reply with quote

Even simpler, just using the power of bash:
Code:
for i in * ; do zip ${i/.exe/.zip} $i ; done

_________________
"Those who deny freedom to others deserve it not for themselves." - Abraham Lincoln
Free Culture | Defective by Design | EFF
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum