1

I have to move a lot of xml-Files, named as follow:

  • F010199004524001_904.XML
  • F010199805946001_737.XML
  • F010199904725001_611.XML
  • F030390114543001_901.XML
  • F030390114544001_257.XML
  • F030390114545001_901.XML

in my batch-file, there's this line:

move C:\source\F01*.xml C:\target\F01\

Now I have the problem, that some of the files have a different 8.3-filename, for example

"F030390114545001_901.XML" has the name "F01FCF~1.XML" so this file is also moved in the directory "F01".

The command "fsutil 8dot3name strip" in my case is useless, because the batch is running on a 2003 server.

Is there any type of workaround or alternative commands to solve this problem?

1 Answer 1

1
for /f %%a in ('dir /b /a:-d "c:\source"^| findstr /i /b "F01"^|findstr /i /e ".xml"') do (
   move "%%~fa" "C:\target\F01\"
)

this?

EDIT

findstr filtering can be done with a single expression -

findstr /beri "f01.*xml"

so

for /f %%a in ('dir /b /a:-d "c:\source"^| findstr /beri "f01.*xml"') do (
   move "%%~fa" "C:\target\F01\"
)
1
  • 1
    I would explicitly match the extension dot using findstr /xri "f01.*\.xml"
    – dbenham
    Apr 30, 2015 at 15:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.