Reputation: 89
I'm trying to find files which contains a string
and print file names with and without extension.
Very important, files are located sub-folders
of main Folder
, I know only path of main Folder
.
This returns 'full path' and extension of files containing word string
:
findstr /s /m "string" c:main Folder\*.txt >list.txt
Desired output: only file name
Cheers, Andy
Upvotes: 1
Views: 1258
Reputation: 80211
@ECHO OFF
SETLOCAL
FOR /f "delims=" %%a IN ('findstr /s /m /i "string" "c:main Folder\*.txt" ') DO (
ECHO full %%a
ECHO name %%~na
ECHO nameext %%~nxa
)
GOTO :EOF
I added /i
for case-insensitivity.
Choose the filename version you want and redirect at will.
Upvotes: 3