I want to shrink some pdfs in a folder using a script and cron.
The main command is as follows:
find . -maxdepth 1 -name "*.pdf" -print0 | xargs -0 -i shrinkpdf.sh -out="./folder/file.pdf" in={}
I want the outfile to have the same name as the in-file, so i tried:
-out=`basename {}`
I don't understand the results. The command between the `` gets executed, but it returns the whole path, not only the basename.
Just playing around with different commands shows, that command substitution generally works.
find . -maxdepth 1 -name "*.pdf" -print0 | xargs -0 -i echo `basename {}`
(echoes the full path)
How can i extract the basename from the arguments given by xargs?!