Jack Waknitz
Jack Waknitz

Reputation: 21

pdftotext find command returning No Such File or Directory

I'm using pdftotext and find to find the contents of a PDF file and move it. I can find all of the files, but trying to add the mv command to the end with xargs returns "No such file or directory" for each file.

My code is as follows:

find ./ -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep -l -Z -i --with-filename --label="{}" --color "Thank you" | xargs -0 -I{} mv {} Found/' \;

Is xargs not getting the correct file path? I'm not sure what is happening.

Upvotes: 0

Views: 914

Answers (1)

Mustafa DOGRU
Mustafa DOGRU

Reputation: 4112

you can get this, when the names contain spaces. Could you try this.

find ./ -name '*.pdf' -not -path "./Found/*"  -exec sh -c 'pdftotext "{}" - | grep -l -Z -i --with-filename --label="{}" --color "Thank you"' \; | xargs -0 -I{} mv {} ./Found/

Upvotes: 1

Related Questions