I am attempting to list the absolute path of all files inside a sub directory. I am able to find and output all files in that sub directory but the file path that I output is incorrect, ie one folder is missing.
My folder structure:
root:
myBatchFile.bat
SearchFolder:
testfile1.txt
testfile1.txt
When I output the file paths for all the files inside the folder 'SearchFolder' they are missing the SearchFolder.
Batch File Output:
C:/user/me/root/testfile1.txt
C:/user/me/root/testfile2.txt
The output should be:
C:/user/me/root/SearchFolder/testfile1.txt
C:/user/me/root/SearchFolder/testfile2.txt
How can I make my Batch file code output the absolute path of the files inside 'SearchFolder'?
REM // For all files in the folder 'SearchFolder': Compile them
for /r %%i in ("SearchFolder/*.txt") do echo %%i
REM // For all files in the folder 'SearchFolder': Compile them
for /r ./SearchFolder %%i in ("*.txt") do echo %%i
This will do for a single folder. Reduce %%a to %a for a command line version.
for %%a in ("d:\abc\*.txt") do echo "%%a"
REM // For all files in the folder 'SearchFolder': Compile them
for %%i in ("SearchFolder/*.txt") do echo %%~Fi
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.