Bug 513819 - Scripting plugin does not work at all in Windows as no environmental variables populated with filenames
Summary: Scripting plugin does not work at all in Windows as no environmental variable...
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Bqm-Script (other bugs)
Version First Reported In: 8.8.0
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-26 00:15 UTC by james anderson
Modified: 2025-12-27 08:15 UTC (History)
2 users (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 james anderson 2025-12-26 00:15:46 UTC
SUMMARY
The scripting plugin is not populating the environmental variables INPUT or OUTPUT which contain the names of the file to be processed and output. This makes it impossible to use the shell plugin in Windows which is a key feature of DigiKam enabling workflow.

The plugin IS invoking the command line interpreter, it is also passing SOME environmental variables, but NOT the filenames. 

STEPS TO REPRODUCE
1.  Open Digikam
2.  Open Batch queue manager
3.  Open any picture file
4.  Add an assigned tool of 'User Shell Script' to the list of assigned tools
5.  Add the line 'set > C:\temp\env_variables.txt' to the list of commands for the batch file to run.
6.  Press the Run button to execute the script
7.   The script will report a failure, that's expected as you haven't done anything. 

OBSERVED RESULT
1. The C:\temp\env_variables.txt lists all environmental variables available to the CMD interpreter when the script was run. It does NOT contain the INPUT or OUTPUT filenames anywhere but the following are listed which appear to be populated (the rating on the picture was 4 stars so this is correct, I didn't test the others):
COLORLABEL=0
COMMENTS=
PICKLABEL=0
RATING=4
TAGSPATH=
TITLE=

EXPECTED RESULT
The INPUT and OUTPUT environmental variables - (or any others that the programming team want to use to put filenames in) are populated and present so that they can be processed by scripts and this feature can be used in Windows.

I have not tested on Linux, though I have it installed as well on that platform, as I want to do the batch processing in Windows in this instance.

SOFTWARE/OS VERSIONS
digiKam: 8.8.0
KDE Frameworks: 6.17.0
Qt: Using 6.9.1 and built against 6.9.1
Windows 11 Version 22H2
Build ABI: x86_64-little_endian-llp64
Kernel: winnt 10.0.22621


ADDITIONAL INFORMATION
This bug was seen by another user earlier this year on an earlier version, https://discuss.pixls.us/t/user-shell-script-on-windows/50864
Comment 1 Maik Qualmann 2025-12-26 07:04:59 UTC
The BQM script works perfectly fine in Windows as well.

The variables $NPUT and $OUTPUT are not stored as environment variables; we can do that if you need them. These variables are directly replaced in the script with the corresponding file paths, using escaped code.

Please post a script example that is not working.

Maik
Comment 2 caulier.gilles 2025-12-26 11:39:35 UTC
James,

Take a look at the online doc here :

https://docs.digikam.org/en/batch_queue/custom_script.html

When you have an example of Windows script working properly on your computer, we can add it as example to the doc.

Best regards

Gilles Caulier
Comment 3 james anderson 2025-12-26 13:57:10 UTC
(In reply to Maik Qualmann from comment #1)
> The BQM script works perfectly fine in Windows as well.
> 
> The variables $NPUT and $OUTPUT are not stored as environment variables; we
> can do that if you need them. These variables are directly replaced in the
> script with the corresponding file paths, using escaped code.
> 
> Please post a script example that is not working.
> 
> Maik

Maik thanks for the super rapid response!
I've re-read the documentation and now understand the issue. I was misled by the Notes section of this part of the manual which says this:
"Under Windows, environment variables can be accessed in the script with % as a prefix and suffix of variable names (for example %INPUT%). The interpreter used to run the script is cmd.exe."

So I just thought that everything would just show up in the environmental variables because that would be a consistent approach and a logical way of doing this, and you're using %INPUT% as an example. If you can populate the variable as well, I'm sure you won't end up with people like me making the same mistake, (and clearly other people are doing the same according to my searches. )

Now that I understand you're doing the substitution in the script I can test that. I'm sure it will work!
James
Comment 4 caulier.gilles 2025-12-26 13:59:43 UTC
James,

When you have a sample script for Windows to provide as example in the documentation, Please share.

Best regards

Gilles Caulier
Comment 5 james anderson 2025-12-26 22:38:40 UTC
(In reply to caulier.gilles from comment #4)
> James,
> 
> When you have a sample script for Windows to provide as example in the
> documentation, Please share.
> 
> Best regards
> 
> Gilles Caulier

Hi Gilles, 
This is effectively your sample bash script translated for Windows:


:: Windows shell example
set infile=$INPUT
set outfile=$OUTPUT

echo INPUT FILE: %infile%  >>c:\temp\digikam.txt
echo OUTPUT FILE:  %outfile% >>c:\temp\digikam.txt

echo TITLE: %TITLE%  >>c:\temp\digikam.txt
echo COMMENT: %COMMENT%  >>c:\temp\digikam.txt
echo COLORLABEL: %COLORLABEL%  >>c:\temp\digikam.txt
echo PICKLABEL: %PICKLABEL% >>c:\temp\digikam.txt
echo RATING: %RATING% >>c:\temp\digikam.txt
echo TAGSPATH: %TAGSPATH% >>c:\temp\digikam.txt

copy %infile% %outfile%
Comment 6 james anderson 2025-12-26 22:44:37 UTC
It would be excellent if Digikam did put the input and output files into environmental variables for DOS alongside all the other values but the implementation is working as designed.  Reason for doing this is then it would be consistent with the approach you are taking with all the other values. thanks!
Comment 7 caulier.gilles 2025-12-27 08:15:27 UTC
Git commit 4c7d9264b24454590352ea6a15be43eaa1855894 by Gilles Caulier.
Committed on 27/12/2025 at 08:14.
Pushed by cgilles into branch 'master'.

add the Windows Shell version of the script in the online documentation.
FIXED-IN:9.0.0

M  +20   -1    batch_queue/custom_script.rst

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