Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy all files in a directory to different name, one by one

Status
Not open for further replies.

longs

Programmer
Jul 27, 2007
31
US
Hello All

I got a question please allow me to explain my problem first.

I have 5 files in a directory;
a.dat
b.dat
c.dat
d.dat
e.dat

I will like to write a script which will cp the files one by one to new file and then do some other work.
so what will happen is;

until file is found
LOOP
cp (file name) to new.dat
run a pl/sql procedure
mv (file name) /to/archive/path/(file name)
end loop

I hope you can understand my problem.
Thanks for all your help.
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
It looks like you could use a construct like:

cd /path/to/directory
for file in `ls *.dat`
do
cp ${file} new.dat
<run a pl/sql procedure>
mv ${file} /path/to/archive/${file}
done

I hope that helps, to get you started.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top