有人請幫忙...哦,我會很感激。我有一個非常長的批處理文件,除了每當用戶輸入輸入時,它都會替換所需文件中的字符串,但是它將刪除文件中的!s,這些文件由於它們是XML配置文件而引起問題,並且這些文件被註釋需要留下的部分。除非要求,否則我不會把整個代碼放在這裏,但是在一個堅果外殼中,用戶進行某些輸入,然後批處理文件運行......這是一個文件的代碼的一部分....用戶進入驅動器安裝信件和bdi服務器的名稱。我希望用戶輸入更換%驅動器%和%bdi1%......這確實....但我不希望它來代替註釋掉部分...即:感嘆號不斷在批處理文件中被刪除
<!-- Tcp message preamble and postamble are flags that mark the beginning and end of an HL7 message. turns into <-- Tcp message preamble and postamble are flags that mark the beginning and end of an HL7 message.
通知沒有!
這是我的代碼...我需要做些什麼來讓它停止刪除!我試着在這裏看,我認爲我很好的方式與傑布的答案,但我無法得到它的工作。在此先感謝
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:server_name=%server%!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:bdi_name=%bdi1%!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:share_name=%share%$!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:drive_bdi=%drive%!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
幫助壓縮它,但不幸的是剛剛創建了一個newfile.txt,並沒有對原始文件做任何事情......並且新的file.txt看起來不正確 –
_the新的file.txt看起來不正確不幸的是一個有點模糊。多一點信息可能會有用。順便說一句。批處理不會嘗試重命名/將newfile.txt複製到original.file,因爲這不是這裏的問題 – jeb
好吧,np,我可以做重命名和所有....但newfile.txt看起來像這樣(摘錄): –