These are the questions I used to build these commands:
- Assign output of a program to a variable using a MS batch file
- The filename, directory name, or volume label syntax is incorrect inside batch
- How to set commands output as a variable in a batch file
If I run the command, by creating a temp file, everything works fine:
"%CYGWIN_ROOT%bin\cygpath.exe" -u "%InstallImprovedSettings%" > motherfockingtemp.txt
set /p InstallImprovedSettingsUnix=<motherfockingtemp.txt
"%CYGWIN_ROOT%\bin\rm" -fv motherfockingtemp.txt
But, creating a file to assign a variable is too much overkill. If I try to do so, without creating temporary and silly files as follows:
FOR /F "tokens=* USEBACKQ" %%g IN (`'%CYGWIN_ROOT%bin\cygpath.exe' -u "%InstallImprovedSettings%"`) do (
SET "InstallImprovedSettingsUnix=%%F"
)
Batch gives the error:
FOR /F "tokens=* USEBACKQ" %g IN (`'C:\CygwinPortable\Cyg win\bin\cygpath.exe' -u "C:\CygwinPortable\Cyg win\cygwin-install-improved-settings.sh"`) do (SET "InstallImprovedSettingsUnix=%F" )
The filename, directory name, or volume label syntax is incorrect.
And if I replace single quotes with double quotes:
FOR /F "tokens=* USEBACKQ" %g IN (`"C:\CygwinPortable\Cyg win\bin\cygpath.exe" -u "C:\CygwinPortable\Cyg win\\cygwin-install-improved-settings.sh"`) do (SET "InstallImprovedSettingsUnix=%F" )
'C:\CygwinPortable\Cyg' is not recognized as an internal or external command,
operable program or batch file.
How can I use commands with spaces on their name?