Computer Hope
Microsoft => Microsoft DOS => Topic started by: tonlo on May 03, 2009, 01:25:08 PM
-
i have 2 text file name: doc.txt and string.txt
Doc.txt
hahah1
kikikik2
fefefefe3
anh3
gugugugu4
String.txt
anh1
anh2
anh3
It was OK when i split my script to two part.
findstr /xnc:%~1 doc.txt
echo %errorlevel%
and
for /f %%i in (string.txt) do echo %%i
But when join 2 of them, i met the problem with %errorlevel%. Anybody can explain for me whats wrong in this case? :'(
@echo off
for /f %%i in (string.txt) do (
findstr /xnc:"%%i" doc.txt
if %errorlevel%==0 echo do nothing
if %errorlevel%==1 echo do something
)
Here is the picture
(http://img141.imageshack.us/img141/1775/catalo.jpg)
-
1. Using Google, study why we use "delayed expansion" in loops
2. Try this
@echo off
setlocal enabledelayedexpansion
for /f %%i in (string.txt) do (
findstr /xnc:"%%i" doc.txt
if !errorlevel!==0 echo do nothing
if !errorlevel!==1 echo do something
)
-
Thanks, Dias.
More question.
How can i insert a string in the end of a file without entering a new line.
needaddcata.txt
41006200730065006E0063006500
43007500730074006F006D0065007200
4D00610069006E00740065006E0061006E0063006500
4F007400680065007200
520026004400
54007200610069006E0069006E006700
My code:
@echo off
setlocal enabledelayedexpansion
for /f "tokens=3 delims= " %%i in ('reg query hkcu\software\microsoft\office\11.0\outlook\categories') do @echo %%i > temp.txt
for /f %%i in (needaddcata.txt) do (
findstr /c:"%%i" temp.txt > nul
if !errorlevel!==1 echo %%i >> temp.txt
)
After my code run, the output file content:
temp.txt
730074006F006D00650072003B004D006100690 06E00740065006E0061006E00630065003B004D 0069007300630065006C006C0061006E0065006 F00750073003B004F0074006800650072003B00 50006500720073006F006E0061006C003B00500 068006F006E0065002000430061006C006C0073 003B005200260044003B0053007400610074007 50073003B005300740072006100740065006700 6900650073003B0053007500700070006C00690 06500720073003B00540069006D006500200026 00200045007800700065006E007300650073003 B0054007200610069006E0069006E0067003B00 5600490050003B00570061006900740069006E0 067003B000000
41006200730065006E0063006500
43007500730074006F006D0065007200
And if the output file was OK, how do i add that content in registry? because its require a hex.
reg add hkcu\software\microsoft\office\11.0\outlook\categories /v MasterList /t REG_BINARY /d " ??? "
My script try to add some categories into MS Outlook "master category list". it just only add the missing category
Make sure you backup for registry before doing anything.
-
everyone pleaseeeee.... :'(