Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7736355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:42:46+00:00 2026-06-01T07:42:46+00:00

setlocal enabledelayedexpansion for /f delims= %%a in (%TempFile2%) do ( set a=%%a set a=!a:

  • 0
setlocal enabledelayedexpansion
for /f "delims=" %%a in (%TempFile2%) do (
    set a=%%a
    set a=!a: =!   
    echo !a! >>%DataFile%
)

I understand that code looks for every “empty space” in tempfile2 data and sets it. What does this line mean ?

set a=!a: =!

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:42:47+00:00Added an answer on June 1, 2026 at 7:42 am

    It’s a basic pattern match and replace.

    Here’s the help from set /?:

    Environment variable substitution has been enhanced as follows:
    
        %PATH:str1=str2%
    
    would expand the PATH environment variable, substituting each occurrence
    of "str1" in the expanded result with "str2".  "str2" can be the empty
    string to effectively delete all occurrences of "str1" from the expanded
    output.  "str1" can begin with an asterisk, in which case it will match
    everything from the beginning of the expanded output to the first
    occurrence of the remaining portion of str1.
    

    The additional twist in your example is that the ‘delayed expansion’ syntax is being used, which uses the ! character as the environment variable expansion character instead of %.

    So the command set a=!a: =! is removing all space characters from the contents of the variable a.

    Delayed expansion is needed (or at least makes something like this a bit easier) because of the way cmd.exe normally expands (then using the % delimiter) the entire set of commands in the block enclosed by parens before executing any part of it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

@echo off SETLOCAL ENABLEDELAYEDEXPANSION set seed=-1 echo seed init val:%seed% for %%f in (*.txt)
SETLOCAL ENABLEDELAYEDEXPANSION FOR %%A IN (*.*) DO ( SET var=%%A ECHO !var:~0,-4! ) Since
I have found this example here : @echo off setLocal EnableDelayedExpansion for /f tokens=*
I wonder why this code does not work as expected: @ECHO off SET S1=HELLO
In the Python Scrapy framework there is a scrapy.bat file: @echo off setlocal %~dp0..\python
I wrote this script to looking for volume with enough free space: @echo on
I have two batch files (XP): test.bat: setlocal EnableDelayedExpansion rem check for argument if
I am trying to make a loop that will go through a set of
I want my Vim to run some commands, such as setlocal spell spelllang=en_us when
In a DOS script that I wrote, I am unable to figure out what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.