Crolog Mark
Crolog Mark

Reputation: 41

Save lines for each file in directory

I'm trying to get all of the files from a certain directory, and save each of the lines.

for /r %%i in (C:\SECMD\Mods\modHandler\ModDir\*.txt) do (
set "file=%%i"
(
echo %%i
set /p Line_1=
set /p Line_2=
echo %Line_1%
) <C:\SECMD\Mods\modHandler\ModDir\%file%
)

pause

But the for command isn't detecting any files, even though I have 2 in the directory. Here's an example of a text file:

C:\SECMD\Mods\modHandler\modHandler.bat
modHandler.bat

I'm aware that the variable is overwritten, I can figure that out after this gets fixed.

Upvotes: 1

Views: 57

Answers (1)

Jaron
Jaron

Reputation: 43

you could try this:

for /F "delims=" %%A in ('dir "%CD%" /b /A:-D')  do (
echo %%A
)

Upvotes: 1

Related Questions