Favorite tools issue with files/folders with spaces

Discussion and questions - donor version.
Post Reply
Message
Author
zbernie
Posts: 41
Joined: 02.01.2020, 16:39

Favorite tools issue with files/folders with spaces

#1 Post by zbernie » 05.01.2020, 06:19

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 "

Marek
Author
Author
Posts: 3973
Joined: 10.04.2006, 09:48
Location: Germany
Contact:

Re: Favorite tools issue with files/folders with spaces

#2 Post by Marek » 06.01.2020, 19:58

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.

zbernie
Posts: 41
Joined: 02.01.2020, 16:39

Re: Favorite tools issue with files/folders with spaces

#3 Post by zbernie » 07.01.2020, 03:57

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'"

stephen147
Posts: 370
Joined: 18.10.2015, 16:44

Re: Favorite tools issue with files/folders with spaces

#4 Post by stephen147 » 16.12.2020, 22:44

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'
Sceenshots made easy with ShareX.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 29 guests