Visit The New, Modern Unix Linux Community


batch shell script to zip individual files in directory - help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting batch shell script to zip individual files in directory - help
# 1  
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  
The first script looks excellent, if you run it like 3gptozip *.3gp
# 3  
Quote:
Originally Posted by era
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  
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  
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  
thanks works ok now
# 7  
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.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #529
Difficulty: Medium
256 possible ASCII characters are enough to represent the wide array of international characters when we consider languages like Chinese Japanese Korean (CJK).
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to zip csv files having specific pattern in a directory using UNIX shell script?

I have files in a Linux directory . Some of the file is listed below -rw-rw-r--. 1 roots roots 0 Dec 23 02:17 zzz_123_00000_A_1.csv -rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_121_00000_A_2.csv -rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_124_00000_A_3.csv drwxrwxr-x. 2 roots roots 6 Dec 23... (4 Replies)
Discussion started by: Balraj
4 Replies

2. Shell Programming and Scripting

Applying the same awk over a directory of files with individual file output

I am trying to apply an awk action over multiple files in a directory. It is a simple action, I want to print out the 1st 2 columns (i.e. $1 and $2) in each tab-separated document and output the result in a new file *.pp This is the awk that I have come up with so far, which is not giving me a... (6 Replies)
Discussion started by: owwow14
6 Replies

3. Shell Programming and Scripting

Need help in batch renaming files with bash shell script.

I have some 50+ files in the following format : abcd_vish_running_ZEBRA_20140818.dat_08-14-2014_23:08:23 abcd_vish_running_ZEB-RA_20140818.dat_08-14-2014_23:08:35 abcd_vish_running_ZEB_RA_20140818.dat_08-14-2014_23:08:37 abcd_vish_running_RI-NG_20140818.dat_08-14-2014_23:08:42... (5 Replies)
Discussion started by: SriRamKrish
5 Replies

4. Shell Programming and Scripting

Using Shell Script in place of Perl script to Unzip the zip files.

Hi Expert, We have some shell scripts which Internally uses Perl Script to Unzip the source zip files which comes to inbound directory. So now our requirement is to avoid the dependency on Perl Script and us Shell Script to unzip the files. I have the Perl script with me attached can some one... (3 Replies)
Discussion started by: naveen.dasu
3 Replies

5. UNIX for Dummies Questions & Answers

Script to remove zip files from a directory

Hi Folks, There is a job which generates a .zip files every day at /usr/app/generated directory , now please advise for the script that will delete this zip files permanently.but while deleting it should make sure that it will not delete the last two days recently generated zip files and this... (1 Reply)
Discussion started by: punpun66
1 Replies

6. Shell Programming and Scripting

Shell Script to zip users cmd history log files

I admit I am terrible with scripting, so when I was asked to store users' command history lines and zip them on monthly basis what I did was to create a file "user_history_Feb" with the following contents: Part A # more user_history_Feb cp -p /var/log/user_history/*history... (6 Replies)
Discussion started by: hedkandi
6 Replies

7. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies

8. Shell Programming and Scripting

HOW: Shell script accessing files located in individual logged in user.

Hi I have below scenario, I hope this could be possible, but as of now no idea how to implement this. Mount point in this location /abc/mp, and there will different users who will be executing one the file shell1.sh file located in /abs/mp, but every user will execute this shell1.sh file from... (1 Reply)
Discussion started by: shekharjchandra
1 Replies

9. Shell Programming and Scripting

Apply 'awk' to all files in a directory or individual files from a command line

Hi All, I am using the awk command to replace ',' by '\t' (tabs) in a csv file. I would like to apply this to all .csv files in a directory and create .txt files with the tabs. How would I do this in a script? I have the following script called "csvtabs": awk 'BEGIN { FS... (4 Replies)
Discussion started by: ScKaSx
4 Replies

10. Shell Programming and Scripting

Converting Shell script to Dos batch files

Hi friends! I am having some simple shell script files to build postgresql database and all. Now i want to convert those scripts to dos batch scripts(to run on windows XP/2000/NT) because there is no need of unix emulation for latest release of postgresql. Please somebody help me. (1 Reply)
Discussion started by: darwinkna
1 Replies

Featured Tech Videos