如何将目录中所有新添加的文件列出到文本文件中?

如何将目录中所有新添加的文件列出到文本文件中?

我正在尝试使用以下代码将目录中所有新添加的文件列到文本文件中,但代码无法正常工作。有人可以提出解决方案或更正代码以满足我的要求吗?我正在使用命令type删除 Temp_File_List.txt 文件的最后一行。

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%

答案1

这是工作脚本:

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%

相关内容