Woodmen Posted August 13, 2009 Share Posted August 13, 2009 Windows XP Home Can the exclaim char be read from a file and written to a file in batch scripting?Here's an input file:--><!-- <<!!---<<<!!-- /--!<!--<*!--<--Here's the script:@echo off>trialnew.txtsetlocal clsfor /f %%# in (trial.txt) do ( echo %%#>>trialnew.txt)Here's the output, all the ! have vanished:--><--<<---<<<--/----<*--<--Thankyou. Link to comment Share on other sites More sharing options...
Yzöwl Posted August 13, 2009 Share Posted August 13, 2009 The following will perform exactly the result of your request!copy trial.txt trialnew.txtA file with that specific content will very likely not be what you have, echoing each line of a file to another will also not be the task you need to perform so in order to receive a reasonable solution you will need to provide specifics. This is one of those questions where any solution supplied will be specific only to that question.Please provide a proper sample file and the full procedure you are wishing to perform on each line of that file!Also, please note that with both the trial.txt and script written exactly as above, the result is exactly what you wanted; (the script works fine). This may mean that you have delayed expansion enabled by default, which is not a good thing IMHO. I'd suggest you run the following at the command prompt to ensure it is disabled before re-trying:REG ADD "HKCU\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 0 /f<Edit>Additionally, the following should be all you'd have needed if that was your proper script.@For /F %%# In (trial.txt) Do @Echo %%#>>trialnew.txt</Edit> Link to comment Share on other sites More sharing options...
Wireless Posted August 13, 2009 Share Posted August 13, 2009 change setlocal to:setlocal disabledelayedexpansion Link to comment Share on other sites More sharing options...
Woodmen Posted August 14, 2009 Author Share Posted August 14, 2009 Thank you both, disabling delayed expansion was the solution.Yzöwl - Yes, the small script and input file shown was just to demonstrate the problem and as you suggested is part of a larger script which includes the removal of text lines at the beginning and end of the input file. Also spot on about delayed expansion being enabled by default, seemed a good idea when it was setup and has now been amended.Am learning - but s-l-o-w-l-y.Again, thankyou. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now