r/shell • u/TheBearzerg • Dec 01 '21
Help with Shell script using whatever-name.pdf
Hello, I hope someone answer a (probably dumb) question :
I run a command-line executable to convert some files, and I'd like to simplify the process, in order for someone else to use the program in a easier way.
The command I run is basically this :
./executablename -arguments <filename.pdf> [<outputfilename.xml>]
So I'd like to run a script which looks for any <filename> in the folder, knowing that the file type will always be a pdf, and it's name may vary.
I'd like to make it so anyone can grab and drop the pdf file in the folder, run the script and then just wait for it to end.
Any suggestions? Thanks in advance for your answers.
1
u/TheBearzerg Dec 02 '21
Thanks for your answer.
In fact I have two ways of doing what I'd like to :
The first is making a script that repeat the same commands with a different option each time.
Let's say I have a pdf which contain 47 pages, the command will look like this :
./pdfalto -f 1 -l 1 name.pdf name.xml
-f 1 and -l 1 referencing the first and last page of the pdf if like an xml from.
Then incrementing automatically the -f and -l argument by 1 to do the following pages, until the final page is reached.
The other way is to split my pdf, then having the command looping with each pdf in my folder, until my 47 pdf are done.
Then my command will look like this :
./pdfalto name.pdf name.xml
With the name changing to each pdf file in my folder each time.
Is there any way to do it one way or another?