What the following command should do, is to search for all invoice pdf files and check if there is a thumbnail file inside the same directory. If not, it should print the directory. Later I will add a command which will create the thumbnails.
find . -maxdepth 2 -type f -name "invoice_*.pdf" -exec sh -c '[ -f "$(dirname {})/thumbnail.jpeg" ] || echo {}' ';'
The command is working, but I besides the filepath I see the following
sh: 1: Syntax error: "(" unexpected (expecting ")")
I guess the filepath gets interpreted as command.
-execdir
instead of-exec
, then you wouldn't need to use$(dirname {})
(you can just test[ -f ./thumbnail.jpeg ]
)-execdir
is a good idea, but I need the path to the pdf file. when I use-execdir
,{}
contains only the filename like./invoice_19805.pdf
(
or)
characters in theinvoice_*.pdf
filenames? try double-quoting the{}
in the echo statement.