Reputation: 3432
I have no previous experience with writing a unix script but what I want seems like a simple task.. I want to run this command for all the pdf files in a folder
pdf2txt.py -o naacl06-shinyama.html samples/naacl06-shinyama.pdf
if there is a file called anypdf.pdf the command would look like:
pdf2txt.py -o anypdf.html samples/anypdf.pdf
so if my folder includes 3 pdf files like, abc.pdf aaa.pdf bbb.pdf I want to end up with abc.html aaa.html and bbb.html
thanks in advance
Upvotes: 0
Views: 254
Reputation: 361565
for pdf in samples/*.pdf; do
html=$(basename "$pdf" .pdf).html
pdf2txt.py -o "$html" "$pdf"
done
If you don't have basename
then try this alternative, which uses bash's ##
and %
constructs to do replacements inline.
#!/bin/bash
for pdf in samples/*.pdf; do
html=${pdf##*/};
html=${html%.pdf}.html
pdf2txt.py -o "$html" "$pdf"
done
Upvotes: 1