Zipping without extension


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Zipping without extension
# 1  
Old 05-14-2015
Zipping without extension

I currently have a code that find and zip all files in current folder and zip it, the problem is the name of the zip will include the extension as well and I don't want it.

for ex:

Volvo-red.swf -> Volvo-red.swf.zip

find . -maxdepth 1 -type f ! -name ".*" -exec bash -c 'zip -r "$0.zip" "$0"' {} \;

What's the trick to ignore the extension and only use the name like?

like: Volvo-red.swf -> Volvo-red.zip

Appreciate any response.
# 2  
Old 05-14-2015
Code:
zip list.zip list.txt

takes list.txt -> zip -> list.zip

This find files *.txt older than 30 days and converts them to zip archive with the name as you want. bash example:
Code:
find . -type f -mtime +30 -name '*.txt' |
while read f
do
  zip ${f/txt/zip}  $f
done

zip archivename filename ...filename ...filename is the syntax.
# 3  
Old 05-15-2015
I'm confused of the code, it seem to zip all into one file. I want to find each file and zip each separately. Anyway to modify from my existing line?

find . -maxdepth 1 -type f ! -name ".*" -exec bash -c 'zip -r "$0.zip" "$0"' {} \;

---------- Post updated at 01:33 PM ---------- Previous update was at 10:25 AM ----------

but avoid including the extension in the name
# 4  
Old 05-15-2015
What keeps you from using jim mcnamara's proposal, eventually adapted a bit to fulfill your needs?
# 5  
Old 05-15-2015
Quote:
Originally Posted by RudiC
What keeps you from using jim mcnamara's proposal, eventually adapted a bit to fulfill your needs?
The code doesn't seem to run. I put them in an executable file as zthis then run ./zthis. The directory have a few test file of .txt. Am I missing something?

I don't understand this line:
zip archivename filename ...filename ...filename is the syntax. Is this part of the code or command line?
# 6  
Old 05-15-2015
That is an example for the syntax. WHAT doesn't seem to run - looks perfect to me...
# 7  
Old 05-15-2015
zip archivename filename ...filename ...filename

correct me if I'm wrong but isn't this line zip all file into one archivename? I want to zip each file into their own zip using the that file as the name.

ex:
Volvo-red.swf -> Volvo-red.zip
Volvo-blue.swf -> Volvo-blue.zip
Volvo-six.swf -> Volvo-six.zip

---------- Post updated at 03:24 PM ---------- Previous update was at 03:04 PM ----------

Nevermind it work now, I have to remove the -mtime +30 not sure why jim include that. Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Zipping

Good Morning, I'd like to archive an old user's files in the home directory on Solaris 9 Will this work? cd home tar -zcvf jsmitharchive.tar.gz jsmith/ ---------- Post updated at 09:37 AM ---------- Previous update was at 09:33 AM ---------- Also- is the last /necessary (after... (4 Replies)
Discussion started by: Stellaman1977
4 Replies

2. UNIX for Beginners Questions & Answers

Zipping the files in UNIX having extension after

Hi Folks I have a logs file at directory cd /opt/app/logs named as coa.log.1 uoa.log.2 erete-rere.log.1 now my concern is that i am looking for unix command which will zip the files having extension log.1 or log.2 or having log. extension anything request you to... (4 Replies)
Discussion started by: neerasri
4 Replies

3. UNIX for Dummies Questions & Answers

Display the .csv extension files based on .done extension fine

Hi All, I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing. 1.I need to display the .done files from the directory. 2.next i need to search for the .Csv files based on .done file.then move .csv files for the one directory ... (2 Replies)
Discussion started by: girija.g6
2 Replies

4. UNIX for Dummies Questions & Answers

Zipping files

Hi All, I have a scenario where in am using uuencode to send a txt file as an excel to end users( email attachment).I have 7 different files and these files are sent as emails 7 times... So my question is, can i not zip all the 7 files at once and attach those files in a single... (9 Replies)
Discussion started by: saggiboy10
9 Replies

5. Shell Programming and Scripting

Help with zipping files

Hi, I have come across a requirement in which I need to zip files. This is fine but the requriement has one conditions like below: One .z file can not have more than 10,000 files Now in the directory I have several files liek below: aaa_file_10_00001.txt aaa_file_10_00002.txt... (6 Replies)
Discussion started by: angshuman
6 Replies

6. Shell Programming and Scripting

zipping files

Dear Experts, I need a script which will zipped the files older than 2 days. but i dont want to use find . * -mtime 2. Is there is any other method to achive this task. i will ececute the script daily. Regards, (3 Replies)
Discussion started by: shary
3 Replies

7. UNIX for Advanced & Expert Users

Help me While zipping the file

Hi , I have written code which will ask the subject,body of the mail, attachment and mail id of the receipient. Code will pick up 4 files zip it. It will zip all the files and then post the mail to the receipient. While zipping the file i am getting error. Can anyone help me with this. ... (7 Replies)
Discussion started by: Jolly
7 Replies

8. UNIX for Dummies Questions & Answers

Zipping

Hi In unix i want to zip the files in a directory excluding *.dmp, *.log, *.lst, *.out files in that directory. pls let me know what command to use. $zip ........ ? Thanks (1 Reply)
Discussion started by: dreams5617
1 Replies

9. Shell Programming and Scripting

zipping in a loop

Hello All, I have a requirement that i need to gzip each file that is more than 5 days old inside a directory. Could some one help me with the script ? do i need to write a for loop or can be done through single command? Thanks, Sateesh (2 Replies)
Discussion started by: kotasateesh
2 Replies

10. Shell Programming and Scripting

Zipping the dir

Hi, Ex: Directory /u01/par If a directory contains all the below files: a.lst b.lst c.lst d.lst ......etc i have 50 files in this directory. How to(command to) zip all the files in this directory into a single zip file. Thanks (1 Reply)
Discussion started by: dreams5617
1 Replies
Login or Register to Ask a Question