windows batch programming - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

windows batch programming

Dear all, I need your help please

I have a batch file on windows.
I need to read from a text file a list of file names, the content of the text file is for example filename1;filename2;filename3

Then, i need to verify in a directory that is an input parameter in the script if the physical files which names are listed in the text file (filename1,filename2...)
exist in this directory; and write output to a text file a message indicating if each file is found or not.

The code i wrote but did not return the desired result is:


echo %date%,%time% Generate list of available and unavailable files >.log.txt

SET /P src_dir="Enter the absolute path for Source Directory where Files are present (including the final ): [e.g: .DATARD]:"
SET /P src_file="Enter the name of file including the list of the names of files (including the extension e.g: .txt):"

ECHO The list of files are in %src_file%
ECHO The physical files are in %src_dir%
FOR /F "delims=;" %%A IN (%src_file%) DO(
set /a COUNTER+=1

IF EXIST %src_dir%%FILENAME% (
ECHO The file you are looking for %FILENAME% has been found in %src_dir%>>.log.txt
) ELSE (
ECHO The file you are looking for %FILENAME% has not been found in %src_dir%>>.log.txt


Can someone help me please?
regards to all

Sign In or Register to comment.