简体   繁体   中英

Batch script set new line to variable in for loop

I have to write batch script which lists all files in directory and writes that list to file. I wrote some script but I have problem with set new line to variable named LinesToWrite.

Could anyone give me some tip ?

@Echo off
set FilesDir= C:\
setlocal enabledelayedexpansion
set LinesToWrite=
FOR %%f IN (%FilesDir%*.*) DO (
    Set LinesToWrite=!LinesToWrite! Started app with file %%f
    )
Echo !LinesToWrite!>lines.txt   

problem was solved thanks to Kennny i fixed my script , now it looks like this.

@Echo off
set FilesDir= C:\
setlocal enabledelayedexpansion
FOR %%f IN (%FilesDir%*.*) DO (
    Echo Started app with file %%f>>Lines.txt
    )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM