It's not possible. There's actually a feature request for this functionality:
Bug 743 – Allow patterns in default prompt answer in custom commands.
Though even that it meant to support only static (non-file) patterns like !/
, but not file patterns like !
.
If it helps, in WinSCP extensions, it's possible to use non-file patterns, like !/
(but not file patterns, like !
) in default prompt/option answer.
The extension file may look like:
@name Unzip...
@side Remote
@command unzip "!" -d "%ExtractionPath%"
@option ExtractionPath -run textbox "Extraction path:" "!/"
Just store the above script to a text file and install it to WinSCP.
Another thing that you can do, is to add a checkbox that will make WinSCP add an archive name (without an extension) to the path, with some clever use of shell (bash) constructs. This way, you can uncheck the checkbox and add a custom subfolder to the target path manually, if you do not want to use the archive name for the subfolder name.
@name Unzip...
@side Remote
@command unzip "!" -d "%ExtractionPath%`[[ '%AddName%' = '1' ]] && AN=! && echo ${AN%.*}`"
@option ExtractionPath -run textbox "Extraction path:" "!/"
@option AddName -run checkbox "Add file name to the extraction path" "1" "1"

Yet another alternative is to use your own placeholder for archive name (e.g. ARCHIVENAME
) that will get replaced by real name (without an extension), when the command is executed. Then, if you do not want to use the archive name for the subfolder name, you replace the ARCHIVENAME
with a custom name.
@name Unzip...
@side Remote
@command unzip "!" -d "`EP=%ExtractionPath%;AN=!;AN=${AN%.*};echo ${EP/ARCHIVENAME/$AN}`"
@option ExtractionPath -run textbox "Extraction path:" "!/ARCHIVENAME"
