|It work with this but It would copy every files to this folder c:\test2\11000 only. I have variable folder the exist already like 11000, 23600, 35000 and the first five digit of a files matched with this folder and I want the files to copy itself to its matching folder. It's so close. I appreciate everyone helping me. I don't know if it can be done. Thank you. |
For /F "tokens=1 Delims=_" %%A in ('dir /b /a-d /s *.dat') Do (
Copy /y %%A*.dat C:\test2\11000
I'm not sure but I think the reason is not working is because it's reading the whole file like 11000_abc.dat to match to folder 11000 and it's not matching up.
If I change the copy to: Copy /y %%A *.dat C:\test2\%%A the message I get is that it can't find the directory
Any idea what I'm missing to make it work?