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

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -