Alan said:
Hello:
I would like to write a batch to swap the char with the following
format!
Original:
"08/01/2003 00:02:26.271","1132","6229"
After Swap:
"01/08/2003 00:02:26.271","1132","6229"
Would you mind to give me some hints?
Thanks!
- - - - - - - - - - begin screen capture - - - - - - - - - -
<Win2000> c:\cmd>demo\FixMySpreadsheet
<Win2000> c:\cmd>type c:\temp\MyNewSpreadsheet.txt
"01/08/2003 00:02:26.271","1132","6229"
"02/08/2003 00:02:27.271","1132","6229"
"03/08/2003 00:02:28.271","1132","6229"
"04/08/2003 00:02:29.271","1132","6229"
<Win2000> c:\cmd>rlist c:\cmd\demo\FixMySpreadsheet.cmd
=====begin c:\cmd\demo\FixMySpreadsheet.cmd ====================
01. @echo off
02. type nul > c:\temp\MyNewSpreadsheet.txt
03. for /f "tokens=*" %%a in (c:\temp\MySpreadsheet.txt) do call :swap %%a
04. :: del c:\temp\MySpreadsheet.txt
05. :: move c:\temp\MyNewSpreadsheet.txt c:\temp\MySpreadsheet.txt
06. goto :EOF
07. :swap
08. set rec=%*
09. set rec=%rec:~0,1%%rec:~4,2%/%rec:~1,2%%rec:~6%
10. echo>>c:\temp\MyNewSpreadsheet.txt %rec%
11. goto :EOF
=====end c:\cmd\demo\FixMySpreadsheet.cmd ====================
- - - - - - - - - - end screen capture - - - - - - - - - -
If this appears to work as you intend, then remove ':: ' from
lines 4 and 5 and you'll be all set.