Bug 512142 - Example in custom script documentation does not handle spaces in path
Summary: Example in custom script documentation does not handle spaces in path
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Documentation (other bugs)
Version First Reported In: 9.0.0
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-15 16:52 UTC by mattbob4
Modified: 2025-12-25 10:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 9.0.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mattbob4 2025-11-15 16:52:36 UTC
SUMMARY
Section found here: https://docs.digikam.org/en/batch_queue/custom_script.html#proof-of-concept

In the context of a custom script, the variables `$INPUT` and `$OUTPUT` are special. The are interpolated by digikam before executing the script. This means that the script will evaluate to something like this before execution:
```
echo "INPUT FILE: "<path/to/input>""
echo "OUTPUT FILE: "<path/to/output>""

echo "TITLE: $TITLE"
echo "COMMENT: $COMMENT"
echo "COLORLABEL: $COLORLABEL"
echo "PICKLABEL: $PICKLABEL"
echo "RATING: $RATING"
echo "TAGSPATH: $TAGSPATH"

cp ""<path/to/input>"" ""<path/to/output>""
exit $?
```
This causes the quotes to cancel out and the copy to fail. Removing the quotes from around `$INPUT` and `$OUTPUT` fixes the issue.

STEPS TO REPRODUCE
1. Run proof of concept from docs using a files with a space in the path.

OBSERVED RESULT
`cp` fails to run

EXPECTED RESULT
script executes correctly
Comment 1 caulier.gilles 2025-11-22 16:03:39 UTC
Git commit b4eb097064115709825f6882d4fffee29f61b90e by Gilles Caulier.
Committed on 22/11/2025 at 15:59.
Pushed by cgilles into branch 'master'.

remove double quote around file paths in the proof of concept script to handle paths with spaces.

M  +1    -1    batch_queue/custom_script.rst

https://invent.kde.org/documentation/digikam-doc/-/commit/b4eb097064115709825f6882d4fffee29f61b90e

diff --git a/batch_queue/custom_script.rst b/batch_queue/custom_script.rst
index ae02b7466..124c7dd3f 100644
--- a/batch_queue/custom_script.rst
+++ b/batch_queue/custom_script.rst
@@ -96,7 +96,7 @@ This first example shown below does nothing special. It prints on the console th
     echo "RATING: $RATING"
     echo "TAGSPATH: $TAGSPATH"

-    cp "$INPUT" "$OUTPUT"
+    cp $INPUT $OUTPUT
     exit $?

 If you have started digiKam from a terminal and enabled the debug traces on :ref:`Setting/Miscellaneous/System dialog page <system_settings>`, you will see something like this: