使用批处理命令查找多个文件

时间:2017-04-12 15:09:20

标签: batch-file

我发现这个有用的命令效果很好。但是,我需要扩展它以查找特定的文件类型

>nul 2>nul dir /a-d "%OutputDirectory%\02_Processing.txt" "%OutputDirectory%\03_Proofs.txt" && (
mkdir "%ARCHIVE_FOLDER%\%DATETIMESTAMP%"
move "%OutputDirectory%\02_Processing.txt" "%ARCHIVE_FOLDER%\%DATETIMESTAMP%"
move "%OutputDirectory%\03_Proofs.txt" "%ARCHIVE_FOLDER%\%DATETIMESTAMP%"
move "%OutputDirectory%\04_Samples.txt" "%ARCHIVE_FOLDER%\%DATETIMESTAMP%"


echo Files moved to "%ARCHIVE_FOLDER%\%DATETIMESTAMP%"

) || (echo No file found)

这样的事情

>nul 2>nul dir /a-d "folderName\file1" or file2 or file3 && (echo Files exist) || (echo No file found)

是否可以在一行中将其拆分为多行。

1 个答案:

答案 0 :(得分:0)

dcg的建议是正确的选择。我错过了变量。所以anser应该是

 >nul 2>nul dir /a-d "%OutputDirectory%\03_Proofs.txt" "%OutputDirectory%\04_Samples.txt" && (^
mkdir "%ARCHIVE_FOLDER%\%DATETIMESTAMP%"
move "%OutputDirectory%\02_Processing.txt" "%ARCHIVE_FOLDER%\%DATETIMESTAMP%"
move "%OutputDirectory%\03_Proofs.txt" "%ARCHIVE_FOLDER%\%DATETIMESTAMP%"
move "%OutputDirectory%\04_Samples.txt" "%ARCHIVE_FOLDER%\%DATETIMESTAMP%"


echo Files moved to "%ARCHIVE_FOLDER%\%DATETIMESTAMP%"

)|| (echo找不到文件)