2017-04-12 91 views
0

我发现这个有用的命令很好用。不过,我需要将它扩大到查找特定的文件类型使用批处理命令查找多个文件

>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) 

是否有可能在一个行做我需要把它分成多行。

+0

您的文件名是否有格式? – dcg

+0

不是。 File1是02_Process.txt,File2是03_Proof.txt,文件3是04_Sample.txt。但是,目录中可能有一个文件01_Convert.txt不能生效 –

+0

如果没有模式只写'> nul 2> nul dir/ad“folderName \ file1”“folderName \ file2”“folderName \ file3”&&(echo文件存在)|| (echo没有找到文件)'看看会发生什么 – dcg

回答

0

dcg的建议是正确的选择。我缺少变量。所以雁应该

>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%" 

)|| (回声未找到文件)

+0

我很困惑这个答案。代码与包含在问题中的代码完全相同。只有一个文件名已经改变。这是什么意思? – Aacini