0

I have found this useful command which works great. However, I need to expand it to find specific file types

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

to something like this

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

is it possible in one line do i need to split it into multiple lines.

TomTommyTom
  • 113
  • 1
  • 2
  • 11
  • Does your file names have a pattern? – dcg Apr 12 '17 at 15:19
  • Not really. File1 is 02_Process.txt, File2 is 03_Proof.txt, File 3 is 04_Sample.txt. However, there might be a file 01_Convert.txt in the directory which cannot be effected – TomTommyTom Apr 12 '17 at 15:22
  • If no pattern just write `>nul 2>nul dir /a-d "folderName\file1" "folderName\file2" "folderName\file3" && (echo Files exist) || (echo No file found)` and see what happens – dcg Apr 12 '17 at 15:26
  • Tried that. Does not seem to be working as expected. Getting "A subdirectory or file \ already exists.... The system cannot find the file specified". Hope this makes sense – TomTommyTom Apr 12 '17 at 15:35
  • I have updated my question with exact copy of my cammands. I'm simply trying to archive off specific file types – TomTommyTom Apr 12 '17 at 15:39
  • If you want to split the command in several lines you have to put a `^` at the end of each line. – dcg Apr 12 '17 at 15:40
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/141574/discussion-between-dcg-and-tom-pisz). – dcg Apr 12 '17 at 15:41

1 Answers1

0

Suggestion by dcg was the right choice. I had missing variables. so the anser should be

 >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 No file found)

TomTommyTom
  • 113
  • 1
  • 2
  • 11
  • I am confused by this answer. The code is _exactly the same_ that the one included in the question; just one file name had changed. What this means? – Aacini Apr 12 '17 at 16:31