Liverpool
Liverpool

Reputation: 131

Batch script find files in a directory

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

Upvotes: 0

Views: 6486

Answers (1)

Endoro
Endoro

Reputation: 37589

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.

Upvotes: 4

Related Questions