문제

I want to print all the C files in a folder (including subfolders) without the path and with suffix .o \ instead of .c. So I found this command that works in cmd:

FOR /F "delims=" %a IN ('DIR /B /S *.c') DO @ECHO %~na.o \"

But when I create a bat file with this command only (one line) I get this output: ~na.o was unexpected at this time.

C:\temp>FOR /F "delims=" ~na.o \"

I undestand from the second line that it has problem with the variable %a. How should i write the above command in a batch file?

도움이 되었습니까?

해결책

Inside a batch file you need to use two %:

FOR /F "delims=" %%a IN ('DIR /B /S *.c') DO @ECHO %%~na.o \"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top