Find a file with the same name in multiple folders that can be anything

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Find a file with the same name in multiple folders that can be anything



Okay, so I have the code


cd ..
cd servers

for /d %%i in (*) do (
cd logs
findstr /R 76561* "*_MA_output_log.txt" >> "......toolspre-results.txt"
)



However, this code doesn't seem to work the way I want it to- that is to say, it does not find the file in the log folder. The directories are structured pretty simply: its ..servers(something)logsand the code itself is in ..tools


..servers(something)logs


..tools



I have researched a bit before asking here, and thats where I got the for loop from but it doesn't work for me.





Did you read the command usage information by entering For /? at the Command Prompt?
– Compo
Aug 11 at 17:01



For /?





@Compo I have updated my code, any suggestions? It still won't work
– LordOfKhaos
Aug 11 at 21:32





1 Answer
1



This code works


cd "%~dp0..servers"
for /f "tokens=*" %%A in ('dir /b /a:d') do (
if exist "%%Alogs" (
echo Found logs folder, switching directories...
pushd "%%Alogs"
if exist "*_MA_output_log.txt" (
echo Found file, executing code
findstr /R 76561* "*_MA_output_log.txt" >> "......toolspre-results.txt"
goto Parse
) else (
echo MultiAdmin output does not exist!
goto End
)
popd
) else (
echo Logs folder not found!
goto End
)
)





Not related to your original problem but if you are looking for 76561 anywhere in the line then the asterisk is not needed and in fact it can give you wrong results ; for instance 76562 will also match . Because you've made 1 optional by 1*
– sst
Aug 12 at 2:01


76561


76562


1


1*






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered