Use of %P with a path with space characters

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
most
Junior Member
Junior Member
Posts: 18
Joined: 2004-01-28, 10:11 UTC
Location: Stockholm / Sweden

Use of %P with a path with space characters

Post by *most »

I have scripts that resize all jpgs in source folder, works fine unless there are spaces in the path.
I found these two posts, but nothing there helped me.
https://www.ghisler.ch/board/viewtopic.php?t=33584
https://www.ghisler.ch/board/viewtopic.php?t=51022

Code: Select all

Command: c:\Progra~1\TotalCmd\Addons\TEST.cmd
Parameters: %P

Code: Select all

[TEST.cmd]
rem Echo just for debuging
echo %1*.jpg 
rem c:\Progra~1\TotalCmd\Addons\magick.exe mogrify -resize 1280x1280 -quality 75 %1*.jpg
Parameters: %P results in {c:\my*.jpg}
Parameters: "%P" results in {"c:\my path"*.jpg}

So double quotes solves the space issue, but adds a another issue.
User avatar
Dalai
Power Member
Power Member
Posts: 9974
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Use of %P with a path with space characters

Post by *Dalai »

Currently, I see two ways to fix this.
  1. Specify *.jpg directly after %P in the button. Then all parameters can be enclosed in quotes:

    Code: Select all

    "%P\*.jpg"
    Note sure about the backslash though.
  2. Leave the button as is (or set quotes around %P), and tell CMD to strip the quotes and explicitly set new ones:

    Code: Select all

    ... "%~1*.jpg"
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
most
Junior Member
Junior Member
Posts: 18
Joined: 2004-01-28, 10:11 UTC
Location: Stockholm / Sweden

Re: Use of %P with a path with space characters

Post by *most »

Thanks! Works great.
Post Reply