0

I need to find all find with extension *.job in a specific folder. But somehow my code not work. However it works when i change *.job to specific name such as INV.job?

if exist "C:\WatchFolder\Incoming\*.job" (
 copy /Y /V "C:\WatchFolder\Incoming\*.job" "C:\WatchFolder\InProgress"
 ECHO TRIGGER AUTOMATIONS
)

Thank for reading

1 Answer 1

4

Try this:

dir "C:\WatchFolder\Incoming\*.job" >nul 2>&1 && (
 copy /Y /V "C:\WatchFolder\Incoming\*.job" "C:\WatchFolder\InProgress"
 ECHO TRIGGER AUTOMATIONS
)

if exist does only work for a specific file, not with wild cards * and ?. copy works with wild cards.

Sign up to request clarification or add additional context in comments.

2 Comments

It would be good to explain why dir && works and what the redirection is for.
dir sets an errorlevel <> 0 if it fails and && executes the following commands only if errorlevel=0. Redirection is for cosmetics, it supresses 1) the normal output and 2) the error messages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.