10/11 Stupid unix question. I have encounter problem like this quite
often and don't know how to deal with it. Let say, I am trying
to rename all the file in a directory, which the new filename
is actually based upon the old filename except the filename
extension... something like
mv *.aaa *.bbb
or, in recent case, I am trying to convert whole bunch pdf files
to text using ps2ascii where i need to supply both input and
output filename, which is only differ in filename extention.
So far, i can only do so in 2 steps, using sed/awk and a temporary
file. Is there anyway I can do that in one single command?
I have tried using find with the -exec, but never get it to
work. Thanks kngharv
\_ not great, but:
bash -c 'for i in `ls *.ps*`; do ps2ascii -o $i $i.txt; done'
it sucks because you'll end up with stuff called file1.ps.txt.
\_ in bash:
for f in *.ps; do ps2ascii $f ${f/.ps/.txt}; done
-abe
\_ in sh:
for i in *.ps; do ps2ascii $i `basename $i .aaa`.bbb; done
\_ in csh/tcsh:
foreach f (*ps)
ps2ascii $f $f:r.txt
end
\_ not working: f: Undefined variable.
\_ I don't think that was a stupid question. Thanks for asking!
\_ For all file rename it is good to use shell command like friend
above say. Using shell command best way renaming many file at once.
\- if you are familar with regular expressions and emacs, there
are various ways to do this using 'dired'.
this is an age-old question in one of the FAQs ... probably
the shell faq. --psb
\_ Thanks all for answering... trying now :p kngharv
\_ /bin/ls *.ps > temp1
vi temp1
!Gawk '{print "ps2ascii",$1,$1}'
:g/.ps$/s//txt/
:wq!
chmod +x temp1
./temp1
\_ whose did you use?
\_ since i am a csh kind of guy, i tried the csh solution.
It didn't work... error message is
f: Undefined variable.
nevertheless, i think this motd message is still helpful
as I will now look at the precise syntax of foreach
statement in csh/tcsh
\_ Try the same thing in tcsh. |