So I am running this command:
FORFILES /S /M *.dmg /C "cmd /c if @fsize equ 1595694080 echo @fname"
and the output:
"058-26174-078"
but the problem is that I want the name without the quotations
like this: 058-26174-078
cmd
shell?You need to use ~
parameter extension together with for /f
to do this.
Use the following command:
for /f %i in ('FORFILES /S /M *.dmg /C "cmd /c if @fsize equ 1595694080 echo @fname"') do @echo %~i
To set a variable, and in a batch file, use the following command:
for /f %%i in ('FORFILES /S /M *.dmg /C "cmd /c if @fsize equ 1595694080 echo @fname"') do @set MyVariable=%%~i
Notes:
%~1
Expand %1
removing any surrounding quotes (")%i
with %%i
and %~i
with %%~i
Use the for command, here is an example:
@echo off
FORFILES /S /M *.dmg /C "cmd /c if @fsize equ 1595694080 set quote=@fname"
for %%a in (%quote%) do set dequote=%%~a
And you can use the %dequote% variable to get the dequoted string, I may have got the syntax wrong because I have never worked with the forfiles command.