For using pdfcrop with a single file only, the empty spaces cause
trouble as expected, because the file name is interpreted as multiple
names.
That is unlikely as you are using a properly quoted parameters in your loop, so no shell word splitting can happen in that case:
for file in *.pdf; do
pdfcrop "$file" "${file%.*}_Cropped.pdf";
done
What could it be then?
Upon inspecting the source code for pdfcrop
, the error you get is defined in:
if ($symlink_exists) {
symlink($inputfile, $inputfilesafe)
or die sprintf "$Error Link from `%s' to `%s' failed (%s)!\n",
$inputfile, $inputfilesafe, exterr;
Which means that a symbolic-link creation was not successful ... pdfcrop
creates symbolic-links to original files with unsafe names prior to processing as stated in the comments part of the linked source code:
# Input files with unsafe file names are linked/copied
# to temporary file with safe file name.
The definition of unsafe filenames can be found in this source code line as a regular expression:
elsif (not $inputfile =~ /^[\w\d\.\-\:\/@]+$/) { # /[\s\$~'"#{}%]/
i.e. (remember these are regular expressions e.g. \w
is a word character and \d
is a digit and \s
is a space and \$
is a literal $
... etc) any of \w\d\.\-\:\/@
are considered safe ... While any of \s\$~'"#{}%
are not considered safe in an input filename.
The actual exterr
(external error) will indicate the reason as for example if a file with the same name of the random link name it's trying to create that error will read something like file exists
... However, in your case the external error reads Operation not permitted
which most likely is because the filesystem on which your working directory resides doesn't support symbolic-links ... For example *FAT*
filesystems don't support symbolic-links ... Therefore, changing your working directory to a filesystem that supports symbolic-links like Ubuntu's EXT4
should solve this issue.