Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

The ! (exclaim) char in Batch Scripting

Featured Replies

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.txt
setlocal
cls

for /f %%# in (trial.txt) do (
echo %%#>>trialnew.txt

)

Here's the output, all the ! have vanished:

-->

<--

<<

---

<<<--

/----

<*--

<--

Thankyou.


The following will perform exactly the result of your request!

copy trial.txt trialnew.txt

A 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>

change setlocal to:

setlocal disabledelayedexpansion

  • Author

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.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.