Skip to main content
rstobbe
Known Participant
March 25, 2023
Answered

Export Action is not called with proper file name if the file name has whitespace

  • March 25, 2023
  • 1 reply
  • 275 views

LR Classic Version: 12.2.1

OS Version: Mac OS Ventura 13.2.1

When exporting images and using a shell script as an export action on MacOS, then if exporting to a path containing whitespace the file name is passed into the export action without escaping the whitespace.

 

Instead of calling

myscript.sh /path\ with\ whitespace

or

myscript.sh "/path with whitespace"

it calls

myscript.sh /path with whitespace

This makes the script operate on three images (which do not exist) instead of the one image.

 

I know a workaround would be to not use whitespace in a path. But if that is not an option, how can I work around this?

 

Thanks and cheers

Ruediger

This topic has been closed for replies.
Correct answer johnrellis

Hmm, I don't observe that.  I set this shell script as a post-processing action:

 

 

#!/bin/sh

echo 1: $1 >> ~/Desktop/echo.log
echo 2: $2 >> ~/Desktop/echo.log
echo 3: $3 >> ~/Desktop/echo.log

 

When I export a file "aaa bbb ccc.jpg", I see this appear in "echo.log":

$ cat echo.log
1: /Users/john/Desktop/aaa bbb ccc-2.jpg
2:
3:

1 reply

johnrellis
johnrellisCorrect answer
Legend
March 26, 2023

Hmm, I don't observe that.  I set this shell script as a post-processing action:

 

 

#!/bin/sh

echo 1: $1 >> ~/Desktop/echo.log
echo 2: $2 >> ~/Desktop/echo.log
echo 3: $3 >> ~/Desktop/echo.log

 

When I export a file "aaa bbb ccc.jpg", I see this appear in "echo.log":

$ cat echo.log
1: /Users/john/Desktop/aaa bbb ccc-2.jpg
2:
3:
rstobbe
rstobbeAuthor
Known Participant
March 31, 2023

Thanks, your script also worked for me which proved that it has to be an issue with my script. So I went back to it and - it's a shame - I process the arguments in a loop and used

for f in $@
do
  ...
done

instead of enclosing it in quotes like:

for f in "$@"
do
  ...
done

Thanks and cheers

Ruediger

johnrellis
Legend
March 31, 2023

Shell-script quoting is always a nightmare.  It's the primary reason programming languages (including scripting languages) shouldn't be based on string substitution.