Need help with wild card syntax to semi-automate file conversion using a perl script
Hi all,
I have a set of files that contain structural data for related RNA molecules that I want to convert from one format to another using a perl script (part of the Vienna package if anyone's familiar). The perl script works like any other: ct2b.pl infile.ct > outfile.seq How can I replace the "infile" and "outfile" names I'm typing in when running the perl script with wildcards such that the name of the outfile will have the same name as the infile (except for the file extensions). Thanks! Kevin |
Wrap some scripting around it - something along these lines might work
Code:
for name in *.ct ; do ct2b.pl $name.ct > $name.seq ; done |
To remove a suffix from a variable when you use it, you can use this syntax:
Code:
${variablename%suffix} Code:
for file in one.ct two.ct three.ct; do Code:
original: one.ct ; no suffix: one ; new suffix: one.seq Code:
for file in *.ct; do Note this will probably overwrite any existing .seq file which has a prefix which exists with a .ct extension. I say probably because the behaviour of the > redirection operator depends on the noclobber setting in the shell. If you want it so that existing files are not overwritten, you should first set noclobber: Code:
set -o noclobber |
Ahhhh - d'oh; thanks matthewg42.
Ignore mine - musta been asleep. |
Good advice. There are two ways to approach this problem: one is to "let the shell do it," and the other is to "let Perl do it." Which one you choose is simply whichever one you're most comfortable with.
|
Thanks! Got it! Really appreciate the help!
|
All times are GMT -5. The time now is 10:59 AM. |