Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
i want to remove the \nul string from this line
"D:\Documents and Settings\fidodido\Desktop\New Folder3\asda\nul"
i tried to use
for /f "skip=1 tokens=* delims=nul" %%I in (text.txt) do echo %%I>>text2.txt
but i found that batch file takes nul as three delims which are n ,u & l and this causes me a problem , so if you could help me with this problem i will be so pleased
text:is the text file contaning the lines , also it is not only one line , they are many lines all ending with \nul"
text2:is my output text file
thanks in advance

@Echo Off > text2.txt
SetLocal EnableDelayedExpansion
For /F "tokens=* delims=" %%j in (text.txt) Do (
Set Row=%%j
Set Row=!Row:\nul=!
Echo.!Row!>> text2.txt)

thanks IVO it worked :)
but could you plz tell me what these lines meanSetLocal EnableDelayedExpansion
Set Row=!Row:\nul=!
Echo.!Row!>> text2.txt
thanks in advance

Your need (erase the \nul string) is just performed by
Set Row=!Row:\nul=!
that replaces the Row's substring \nul with the "nul" string.
As you see, the value of the environment variable Row is referred by coding !Row! instead of the usual %Row%.
Here Row is used as "Dynamic Variable", i.e. it is expanded at run time catching each line of the text file while the For loop goes on. Otherwise %Row% would just be empty as it would be freezed at its state at the beginning of the loop.
To enable dynamic variables the SetLocal statement must be coded and delayed expansion needs to be used any time environment variables have to be referred inside compound statements (embraced by ()).
To get a short and not friendly tutorial on the subject type Set /? at prompt.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |