shell - unix script, running a command on multiple files -
i have no previous experience writing unix script want seems simple task.. want run command pdf files in folder
pdf2txt.py -o naacl06-shinyama.html samples/naacl06-shinyama.pdf
if there file called anypdf.pdf command like:
pdf2txt.py -o anypdf.html samples/anypdf.pdf
so if folder includes 3 pdf files like, abc.pdf aaa.pdf bbb.pdf want end abc.html aaa.html , bbb.html
thanks in advance
for pdf in samples/*.pdf; html=$(basename "$pdf" .pdf).html pdf2txt.py -o "$html" "$pdf" done
if don't have basename
try alternative, uses bash's ##
, %
constructs replacements inline.
#!/bin/bash pdf in samples/*.pdf; html=${pdf##*/}; html=${html%.pdf}.html pdf2txt.py -o "$html" "$pdf" done
Comments
Post a Comment