batch script for creating folders and moving files
Posted on 2011-02-23
I have files with a name in the format of -> 12345678_ordrsp.test
What I am trying to do is take the first 8 characters "12345678" which would be custno
and the characters 10-15 "ordrsp" which would be messagetype.
I would then copy the file to one folder and then move the original file to another.
My code so far:
dir /b c:\edi_out\*.xml > filelist.txt
REM append .xml to all files
rename *_*.* *.*.xml
for /F "tokens=*" %%F in (filelist.txt) do (
xcopy "%%~F" "C:\backup\%custno%\%messagetype%"
move "%%~F" "C:\%custno%\%messagetype%"