Running a script with all files in a folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running a script with all files in a folder
# 1  
Old 12-15-2009
Running a script with all files in a folder

Hi

I have many files in a folder (like 200) and I want to run a Perl script through all of them. One way would be to do it one by one (which will take forever). But I am sure there is a faster way of doing it.

So inside the folder i have files named in no particular way

eg.
YUI456
YAR234
etc.
etc.

So the perl scrip i am running is like this

perl get-feature.pl rr FILENAME gg OTHERMATCHFILE

the "OTHERMATCHFILE" is the file taht i want to match with all the files inside the folder.

thanks
# 2  
Old 12-15-2009
Code:
perl filename.pl *

* will be expanded by shell with all the filenames in that directoy.
# 3  
Old 12-15-2009
Hi I am having some problems with only using the *

I found an alternative solution but there are some errors.

Code:
find ./ -name '*' -exec sh -c 'perl.pl -rr  -ff MATCHFILENAME {} \> {}.txt' \;

basically I want to run each file in the folder through this script then spit out the output file with the .txt ending

Last edited by phil_heath; 12-15-2009 at 03:33 PM..
# 4  
Old 12-15-2009
Quote:
Originally Posted by phil_heath
[...]
basically I want to run each file in the folder through this script then spit out the output file with the .txt ending
...and it would've been helpful if you'd have said so in your original post...

Try something like this:
Code:
ls * | grep -v 'txt$' | while read file
do
    perl.pl -rr -ff $file > $file.txt
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. UNIX for Dummies Questions & Answers

Script to delete files in different folder

Hi Experts, i need a little help. i have different folder that contain files that need to be deleted. but those folder contains huge amoung of same with 3 different extention. what i used to do is to delete them using the rm commande rm *.ext *.ext1 *.ext3 what i want to do is to have... (1 Reply)
Discussion started by: yprudent
1 Replies

3. UNIX for Dummies Questions & Answers

Script to pick the files from source folder

Hi, I wrote a script to pick files based on some logic. when I execute my script, I get the below message ( I bolded the lines in the script where this error message shows up), it says that files are not available and it is a valid scenario if the files are not available and I don't know how... (9 Replies)
Discussion started by: Vijay81
9 Replies

4. Shell Programming and Scripting

Need script using cp to transfer files to another folder

Hi guys , how are you doing? I am tryng to make a script using cp that i would like to do this: echo "Enter the name files to tranfer" then user has to enter via keyboard this kind of output file1 file 2 file 3 file x (i mean the number of the files could vary and their name too)... (1 Reply)
Discussion started by: REX:)
1 Replies

5. UNIX for Dummies Questions & Answers

Script for checking the files in a folder

Hi , I am using the below script for checking for a file in a folder. if ; then echo 0 else echo 1 fi Is there any way we can check for files which are starting with GL*.csv.What I am trying to do is , I have to check in a folder for the GL*.csv files if there are any files they I... (6 Replies)
Discussion started by: wangkc
6 Replies

6. Shell Programming and Scripting

Rename folder/directory after running sort script

Hello, I'm trying to create a script that sorts documents by author (found in file name) and then create a directory for that author. For example, Input: John - Paper_1.txt John - Paper_2.txt Mark - Paper_1.txt Jill - Paper_1.txt Output: dir/John/Paper_1.txt dir/John/Paper_2.txt... (1 Reply)
Discussion started by: jl487
1 Replies

7. Shell Programming and Scripting

Script for moving files from one folder to other

Hi I need to move last 1 year old files from one folder to another location on same server.How to write a shell script for the same? thanx Lalit (8 Replies)
Discussion started by: lalitkumar
8 Replies

8. Shell Programming and Scripting

Script for moving files from one folder to other

Hi All I need a shell script for move the 1 year old files from one folder to another folder with date and time. How to write a shell script for the same pls hepl me out. thanx in advance Thanx Lalit (2 Replies)
Discussion started by: lalitkumar
2 Replies

9. Shell Programming and Scripting

script for Finding files in a folder and copying to another folder

Hi all, I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt. I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Discussion started by: satish2712
5 Replies

10. UNIX and Linux Applications

read files from folder and then call another script

Hi, I am new to the Unix shell scripting world. It would be great if some body can help me with my requirement 1) Script (say script1.sh) which will take set of files from one folder (say input folder). 2) Take the first file from the folder and execute another script (script2.sh).Pass 2... (1 Reply)
Discussion started by: girishnn
1 Replies
Login or Register to Ask a Question