|
Answer» I have a batch file to check and see if files exist and if so then list them in a txt file - something like this:
Code: [Select]cls if exist %System%\abc123.dll echo %System%\abc123.dll>>%systemdrive%\found.txt I would like to have a text file that lists files it is searching for - example:
Code: [Select]%system%\abc123.dll %systemdrive%\def456.dll %temp%\ghi789.dll I would like the batch file to be able to step through each line of the text file instead of entering all the files into the batch program. Is this possible and how would I do it? Thanks for any suggestions and advice. This may work:
Code: [Select]@echo off for /f "tokens=* delims=" %%i in (path\filename.ext) do ( if exist "%%i" echo "%%i">>%systemdrive%\found.txt )
CHANGE path\filename.txt to whatever you need. Batch language is very specific to each version of Windows. Please mention your Windows version in the future.
Happy Computing. 8-)Siewinder, where HAVE you been? Thank you for your help so far. I would like to be able to run this on 98 and XP machines but mainly XP. When I tested your script it stepped through the list very nicely but when the file existed it did not append the found.txt :-?I doubt this script will run on Win98. Batch language is specific to each version of Windows. Each version is backward COMPATIBLE with previous version but not vice versa.
I THINK the problem is that the ECHO statement will not expand the system variables in the file, THINKING that it's just data. Try hardcoding the file names. I tried this with delayedexpansion but that doesn't seem to work either.
You could ALWAYS write a VBScript which is installed free with all Windows versions. You would have more control and be able to work with each record in the file before redirecting to the output.
Good luck. 8-)Thank you. I will look into that. Do have know of a good resource or two for writing VBScript?Quote Thank you. I will look into that. Do have know of a good resource or two for writing VBScript?
i came up with this link http://podgoretsky.com/ftp/Docs/VBScript/. you can have a look. There are other links too, if you search hard enough. good luck I just wanted to report back that after removing the quote marks the proposed method woks nicely. See below:
Code: [Select]@echo off for /f "tokens=* delims=" %%i in (path\filename.ext) do ( if exist %%i echo %%i>>%systemdrive%\found.txt ) THANKS FOR YOUR HELP
|