Need help on Mulitple files mutliple actions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help on Mulitple files mutliple actions
# 1  
Old 01-16-2009
Need help on Mulitple files mutliple actions

Hi all,

I have mistkanely gzipped twice an entire folder and sub folders, and also renamed the files during that process.

I am trying to undo this, and I need help to create the batch to work on it.

All folders are under my images directory, I have a output.txt file that holds all the names of the files, the process I need to do for each file is:

gunzip $i
rename the file from: XXX.pngzip to XXX.png.gz
gunzip $1 (2nd time)

This process works manually, but I aint gonna do it for 2500+ files (not even as a good learning lesson :-/

I am buffeled on my options, and can't really make my simple script work, I might not go the right direction, or just can't see the simple one.

I would like your advise.

Running the batch ofc will be run from the top folder, and all files will have to stay in the same place.

Code:
#!/bin/bash

for i in 'find -name *.pngzip.gz'
do
gunzip $i
#rename the file
gunzip $i
done

I don't mind using my output.txt file with all listed files as input, but I am trully lost.

thanks
# 2  
Old 01-16-2009
OK,
I have done some more changes, and I have written a working code:


#!/bin/bash

for i in `cat dirs.txt`

do
# echo $i
pushd $i
gunzip *.pngzip.gz
rename .pngzip .png.gz *pngzip
gunzip *.png.gz
popd
done


It works on the list of ALL dirs so it's ok.

Thank you, if you have comments, ill be happy to learn more.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Load mutliple files into Netezza table

Hi All, I get ~1000 files everyday and the current unix script process one file at a time... like it unzips the file, loads into table . This process will repeat how many ever files were present in the directory. I was wondering can we process multiple files (like unzipping and loading X amount... (1 Reply)
Discussion started by: rajasony
1 Replies

2. Shell Programming and Scripting

substitution to mulitple files

Hello all, I am trying to make a script that will apply a substitution to any number of files given on the command line. Example would be ~/Unix/script/subst car boat myFile1.txt myFile2.txt myFile3.txt This is the code I have so far but it does not function as needed. PAT=$1 shift... (10 Replies)
Discussion started by: ramn214
10 Replies

3. UNIX for Advanced & Expert Users

FTP failed to copy mulitple files from multiple directory

I am using below scripts to copy all the files from multiple folders. By executing individually command i am able to copy all the files but using scripts only getting first file. System is ignoring the second CD and mget command. HOST=server.com USER=loginid PASSWD="abc" echo "open $HOST... (6 Replies)
Discussion started by: meetvipin
6 Replies

4. Shell Programming and Scripting

Help with Find/Replace Javascript Injected Strings in mulitple files

Hi, guys, I'm not a high-end programmer, but I've been trying to write a script to remove all of the b.rtbn2.cn (and b.adserv.cn and any future variation) injected script tags on the server. (Still working on security fixes to prevent it in the future, just need to clean up now.) My approach is... (1 Reply)
Discussion started by: zzlegs
1 Replies

5. Shell Programming and Scripting

Opening Mulitple files using For loop in Perl

Hi All, I have a total of ten file to open in the Perl script and i am using a for loop to open each file and capture some strings inside each file. Unfortunately, i encounter the below syntax error. I think there should be something wrong with this term reports_${counting}_${_}.txt but i do... (4 Replies)
Discussion started by: Raynon
4 Replies

6. Shell Programming and Scripting

taking count of log files and den performing some actions

hi, I've some log files in a path /SYSTEM/custom/data/MNP/xmlerror as: MNP_PORT_IN_P200902191347563283_20090220181630_err_1.xml MNP_PORT_IN_P200902171717114365_20090220211814_err_2.xml MNP_PORT_IN_P200902191349023233_20090220181923_err_1.xml... (4 Replies)
Discussion started by: ss_ss
4 Replies

7. Shell Programming and Scripting

mutliple files in the same directory

I have over 900 files that have the same name except for a unique numeric assignment. For all files I would like to cut the 2nd column and paste all into one new file. All in bash. sample input format for each file: 1 2 3 1 2 3 1 2 3 sample command for what I want to do: cut -d' ' -f2... (8 Replies)
Discussion started by: epi8
8 Replies

8. UNIX for Dummies Questions & Answers

process mutliple files in the same directory

I have over 900 files that have the same name except for a unique numeric assignment. For all files I would like to cut the 2nd column and paste all into one new file. All in bash. sample input format for each file: 1 2 3 1 2 3 1 2 3 sample command for what I want to do: cut -d' ' -f2... (1 Reply)
Discussion started by: epi8
1 Replies

9. UNIX for Dummies Questions & Answers

Please Help:Need to Split the file into mutliple files depends on the KEY field value

Hi Gurus, I am new to UNIX(HP). my requirmnet is File needs to needs to be split into multiple files dependa on one key value. example 1 abc 333 us 2 bbc 444 ch 5 nnn 333 kk 7 hhh 555 ll 3 hhh 333 hh now the requirment is line with 333 should be copied into test1.txt and... (14 Replies)
Discussion started by: arund_01
14 Replies

10. AIX

Script to perform some actions on multiple files

I have this Korn script that I wrote (with some help) that is run by cron. I basically watches a file system for a specific filename to be uploaded (via FTP), checks to make sure that the file is no longer being uploaded (by checking the files size), then runs a series of other scripts. The... (2 Replies)
Discussion started by: heprox
2 Replies
Login or Register to Ask a Question