0

I am new to bash scripting and I have a small code that takes PDF as input, do some manipulation and returns the PDF. But it does one file at a time, so we have to run it for each file.

The code can be run as below where "hello" is the code.: -

hello path_to_original_pdf path_to_updated_pdf

I need to write a Bash script that read files from a folder one by one, performs the operation "hello" on each file and then saves the updated PDF into the output folder.

I tried something like :-

target = "path_to_updated_pdf"
for filename in "path_to_original_pdf"/*
do
    hello $filename $target
done;

Can someone suggest if this is the correct way to do it?

av25
  • 11
  • 1
  • Take around the spaces around the `=`, add missing quotes, and you're pretty much there. – Charles Duffy Oct 25 '19 at 16:42
  • That said, note that we ask that each question be about one *specific* problem, asked after looking for other questions about that problem already in the knowledgebase. In this case, you had two problems (the assignment not working, and the expansions not being quoted to ensure that each results in only exactly one argument), both of which are already in our knowledgebase. – Charles Duffy Oct 25 '19 at 16:44
  • ...btw, http://shellcheck.net/ is a good resource; it's always worth running code through and fixing what it finds before asking questions here. – Charles Duffy Oct 25 '19 at 16:45

0 Answers0