Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to list all the newly added files of a directory to a text file using below code but the code is not working properly. Can anyone suggest a solution, or correct the code to meet my requirements? I am using the type command to delete last line of the Temp_File_List.txt file.

rem this batch script is used to list all the files created newly to a landing directory.
set LandingDir=C:\Documents and Settings\Shivam\Desktop\LandingDir\*.txt
set DateFile=C:\Informatica\PowerCenter8.6.0\server\infa_shared\SrcFiles\DateFile.txt
set Temp_FileList=C:\Informatica\PowerCenter8.6.0\server\infa_shared\SrcFiles\Temp_File_List.txt
set FileList=C:\Informatica\PowerCenter8.6.0\server\infa_shared\SrcFiles\File_List.txt
set /P _PreviousDate=<%DateFile%

xcopy "%LandingDir%" /l /s /d:%_PreviousDate% .>%Temp_File_List%
type "%Temp_File_List%" | findstr /v File>%File_List%
echo %date:~4,2%-%date:~7,2%-%date:~10,4% >%DateFile%
share|improve this question
    
Please can you edit your question so that your code is formatted as code? Doing so will make it easier to read. –  john May 13 '12 at 19:45
    
Which part is it that is not working? –  john May 13 '12 at 20:02
    
By the way, you are missing an underscore in your set Temp_File_List = ... statement. Everywhere else you refer to it with an underscore. –  john May 13 '12 at 20:04
    
And the same with set File_List = ... –  john May 13 '12 at 20:14
    
yah i have corrected those lines and inserted the underscore the script is working but not as expected.here it should list all the files which are added after the PreviousDate but not all.the script is listing all the files please suggest something to avert this –  Hal May 13 '12 at 20:39

1 Answer 1

Here's the working script:

rem this batch script is used to list all the files hosted newly to a landing directory.
set LandingDir=C:\Documents and Settings\Shivam\Desktop\LandingDir\*.txt
set DateFile=C:\Informatica\PowerCenter8.6.0\server\infa_shared\SrcFiles\DateFile.txt
set Temp_File_List=C:\Informatica\PowerCenter8.6.0\server\infa_shared\SrcFiles\Temp_File_List.txt
set File_List=C:\Informatica\PowerCenter8.6.0\server\infa_shared\SrcFiles\File_List.txt
set /P _PreviousDate=<%DateFile%

xcopy "%LandingDir%" /l /s /d:%_PreviousDate% .>%Temp_File_List%
type "%Temp_File_List%" | findstr /v File>%File_List%
echo %date:~4,2%-%date:~7,2%-%date:~10,4% >%DateFile%
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.