script for multiple files

Hey guyz,

I am using an application called "bigWigToBedGraph"
It has to be used like this in a folder contained the app and the fils:

bigWigToBedGraph in.bigWig out.bedGraph

Now, I have many files which I put them in one directory. They are all bigWig files. I wanna convert them to bedGraph. But I don't want to write the command line 100 times for all of them!!

Is there any way to convert them all at once and keep their names but just change the extensions?

Thanks!

for i in *.bigWig
do
 bigWigToBedGraph $i ${i/%bigWig/bedGraph}
done

Thanks man!
It seems it's working. :wink:

Try something like this..

for i in *.bigWig
do
file_name=$(echo $i | sed 's/.bigWig/.bedGraph/g')
bigWigToBedGraph $i $file_name
done