1.

Solve : How to exlude parts of a filename?

Answer»

I have files in my FOLDER:

C:\files\002-31234567.dat
C:\files\002-31234568.dat
C:\files\005-51234567.dat

and I want to copy them to another folder WITHOUT the 002- and 005- PART.

So I get:

C:\copy\31234567.dat
C:\copy\31234568.dat
C:\copy\51234567.dat

I've tried "copy c:\files\002-*.dat c:\copy\*.dat" but that copies the 002- part too.

How can I LEAVE the first 4 characters out of the filename?




Welcome to CH Forume!!

type the following command in dos prompt.

Code: [Select]for /f "tokens=1,2 delims=-" %a in ('dir c:\files\*.dat /b') do copy c:\files\%a-%b C:\copy\%bThanks! That did the trick!



Discussion

No Comment Found