Sport Girl Posted March 26, 2010 Report Share Posted March 26, 2010 Dear all, I need your help pleaseI 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;filename3Then, 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 OFFecho %date%,%time% Generate list of available and unavailable files >.\log.txt:start_of_fileSET /P src_dir="Enter the absolute path for Source Directory where Files are present (including the final \ ): [e.g: .\DATA\RD\]:"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%set COUNTER=0:TESTFOR /F "delims=;" %%A IN (%src_file%) DO( set /a COUNTER+=1set FILENAME!COUNTER!=%%Agoto TEST_FILE_EXISTENCE):TEST_FILE_EXISTENCEIF EXIST %src_dir%%FILENAME% (ECHO The file you are looking for %FILENAME% has been found in %src_dir%>>.\log.txtGOTO TEST) ELSE (ECHO The file you are looking for %FILENAME% has not been found in %src_dir%>>.\log.txtGOTO TEST)Can someone help me please?regards to all Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted March 27, 2010 Report Share Posted March 27, 2010 Welcome to the Windows Forum.The code i wrote did not return the desired resultWhat was the result that you got?I see that you have several ECHO commands in it, which of course is great for debugging. Did you get the correct values from the ECHO commands? Can you post the complete output of this script? Quote Link to comment Share on other sites More sharing options...
Sport Girl Posted March 28, 2010 Author Report Share Posted March 28, 2010 well the log was the following Sat 03/27/2010,12:51:19.95 Generate list of available and unavailable files for SGBL The list of SGBL files are in SGBL_FILES_LIST.txtThe physical SGBL files are in D:\Fermat\Scripts_chargement\fermat\Dynamic\Data\SGBL\05102009\need ur suggestions please Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted March 29, 2010 Report Share Posted March 29, 2010 It looks like the ECHO commands in section TEST_FILE_EXISTENCE are never executed. Add more ECHO commands, e.g. to test the contents of COUNTER, FILENAME.Just do some basic debugging; we cannot do that for you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.