The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to count files and get the disk usgae on individual mail folders phpfreak Shell Programming and Scripting 1 05-17-2008 05:15 PM
shell script to find and copy the files creted in the year 2006 to another directory manas6 Shell Programming and Scripting 2 04-01-2008 04:04 AM
shell script: deleting files from a directory onlyc Shell Programming and Scripting 1 07-09-2006 07:41 AM
Converting Shell script to Dos batch files darwinkna Shell Programming and Scripting 1 05-12-2006 12:01 PM
UNIX Shell script to chec timeout period when collecting files in directory - HELP Danny Fang Shell Programming and Scripting 1 03-23-2006 08:41 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-28-2008
wingchun22 wingchun22 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 19
batch shell script to zip individual files in directory - help

help trying to figure out a batch shell script to zip each file in a directory into its own zip file

using this code but it does not work

Quote:
#!/bin/bash
echo "3gptozip converter"
for f in "$@"
do
zip -j "$f.zip" "$f"
done
echo "Finished with 3gptozip converter"
tryed this also

Quote:

#!/bin/bash
echo "3gptozip converter"
if (($# ==0))
then
echo "Usage: 3gptozip [3gp files] ..."
exit
fi
while (($# !=0 ))
do
zip $1.zip $1
shift
done
echo "Finished with 3gptozip converter"
nothing seems to work , just ends without zipping any files

i have over 3000 files i need to zip up individualy

files to be zipped are in this format 123.flv.3gp

hopfully ending up like 123.flv.3gp.zip

is the file structure the problem

running a single zip command from shell seems to work ok

thanks for help in advance
  #2 (permalink)  
Old 08-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
The first script looks excellent, if you run it like 3gptozip *.3gp
  #3 (permalink)  
Old 08-28-2008
wingchun22 wingchun22 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 19
Quote:
Originally Posted by era View Post
The first script looks excellent, if you run it like 3gptozip *.3gp

sorry to be a bit stupid but how or what do i change and where to make this work
am i not doing the

zip -j "$f.zip" "$f"


part right


or is there a problem, in the echo commands

i was tying to run it with

nohup ./3gptozip.sh &

and

./3gptozip.sh

but is that the problem

thanks, i'm new to shell scripting by the way
  #4 (permalink)  
Old 08-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
The problem is that you need to list the files you want to zip on the command line, the script doesn't contain this information. "$@" contains the arguments passed to the script on the command line.
  #5 (permalink)  
Old 08-28-2008
wingchun22 wingchun22 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 19
how whould i do that in shell ??

is it something like

nohup ./3gptozip.sh *.3gp &

or

./3gptozip.sh *.3gp

or is that the incorrect way to do it, thanks for help by the way
  #6 (permalink)  
Old 08-28-2008
wingchun22 wingchun22 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 19
thanks works ok now
  #7 (permalink)  
Old 03-08-2009
jennyenve jennyenve is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 1
zip individual files

how to zip individual files (.txt) into its own zip file.
is it something like

directory name 'test'

for file in test/* do zip $file.zip $file.txt?
it's not working. please help.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0