For this I am calling the following command in run_rename.bat file:
Code: Select all
for /f "usebackq delims==" %%a IN (`dir /b *4869*.txt`) do call renameFile.bat %%a
And the renamefile.bat has the following code:
Code: Select all
'net use P:\
CD C:\temp
REM
REM
setLocal DisableDelayedExpansion
REM Rename File to X.xml to enable change of text
if exist X.xml del X.xml
REM ren email_4869_12345.txt X.xml
ren %1 X.xml
REM @echo off > XXX
setLocal DisableDelayedExpansion
for /f "tokens=* delims= " %%G in (X.xml) do ( set str=%%G
setLocal EnableDelayedExpansion
REM set the string "12345 " to be "56789 "
set str=!str:12345 =56789 !
REM generate a new file with the rename in place
REM >> email_4869_12345.txt echo(!str!)
>> %1 echo(!str!)
del X.xml
This code is chopping off '!' from the text file and replacing nothing and taking the character off.
For example:
if the file has 'when!', the script is deleting '!' and taking the position off in the generated file.
Can anybody suggest where is it going or suggest me how to suppress this?
Thanks.