I want to make cmd type all files in its own variable. example:
C:\>dir/b systemlogs.txt projects.bat C:\>echo %file1% systemlogs.txt C:\>echo %file2% projects.bat
Any tips? Any code i can use?
I want to make cmd type all files in its own variable. example:
C:\>dir/b systemlogs.txt projects.bat C:\>echo %file1% systemlogs.txt C:\>echo %file2% projects.bat
Any tips? Any code i can use?
try this:
@echo off &setlocal enabledelayedexpansion
set /a counter=0
for %%i in (systemlogs.txt projects.bat) do (
set /a counter+=1
set "file!counter!=%%i"
)
set "file"
..output is:
file1=systemlogs.txt
file2=projects.bat
Something like this should work:
@echo off
setlocal EnableDelayedExpansion
cd /d "C:\some\folder"
set a=0
for %%f in (*) do (
set /a a+=1
set "file!a!=%%~ff"
)
set b=0
for /d %%d in (*) do (
set /a b+=1
set "folder!b!=%%~fd"
)
for /l %%i in (1,1,%a%) do echo %%i: !file%%i!
for /l %%i in (1,1,%b%) do echo %%i: !folder%%i!
endlocal