Page 1 of 1

Favorite tools issue with files/folders with spaces

Posted: 05.01.2020, 06:19
by zbernie
I have a favorite tools item named "Combine Images Horizontally" which takes highlighted image files and combines them horizontally. It executes a powershell wrapper script around ImageMagic. It works fine EXCEPT when the files contain spaces. I've tried quoting some of the parameters such as "%ActiveDir"" and %ActiveSelName%", and numerous other quoting syntax, to no avail. Listed below is the favorite tool I'm referring to. This is using FC 810 donor version.

Any suggestion to get this working would be greatly appreciated.


Program or folder:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Start folder:
%ActivDir%

Parameter:
C:\Users\bernie\PowerShell\im-combine-images-horizontally.ps1 %ActivSelName%

, Delimiter character for selected items

Checked Enclose each item with "

Re: Favorite tools issue with files/folders with spaces

Posted: 06.01.2020, 19:58
by Marek
Try to add the %Dlg% parameters:
C:\Users\bernie\PowerShell\im-combine-images-horizontally.ps1 %ActivSelName% %Dlg%

Then you can see in the dialog how FreeCommander will start the favorite.
We do not know what you have in the script, you must know if the parameters are OK or not.

Re: Favorite tools issue with files/folders with spaces

Posted: 07.01.2020, 03:57
by zbernie
Thanks, I've used the %Dlg% which is very useful. The problem is the bizarre Windows quoting necessary for files/folders containing spaces. I found the two quoting methods below work from the command line. I'm going to try and duplicate this in FreeCommander.

PS C:\Users\bfbarton\Powershell> C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\Users\bernie\Powershell\test2.ps1 "'Infosec1.PNG', 'Infosec2.PNG', 'WriteFile - Copy.ps1'"

PS C:\Users\bfbarton\Powershell> cmd /S /C powershell "C:\Users\bernie\Powershell\test2.ps1 'Infosec1.PNG, Infosec2.PN
, WriteFile` -` Copy.ps1'"

Re: Favorite tools issue with files/folders with spaces

Posted: 16.12.2020, 22:44
by stephen147
Try this thread on SO. https://stackoverflow.com/a/5592684/8262102

I think you need to handle it like this and set the param as a string and wrap your parameter in the toolbar with ".

Here's my first example for FC.

Program of folder:

Code: Select all

powershell.exe
Paramter:

Code: Select all

-file "C:\yourpathto\hellome.ps1" -param "Hello Me!!"
.ps1 file contents:

Code: Select all

#Must be the first statement in your script (not counting comments)
param([String]$param="")
write-host $param
cmd /c 'pause'