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 3323338
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:17:26+00:00 2026-05-17T23:17:26+00:00

I realise that you can escape ampersands in batch files using the hat character

  • 0

I realise that you can escape ampersands in batch files using the hat character

e.g.

echo a ^& b
a & b

But I’m using the command

for /f "tokens=*" %%A IN ('DIR /B /A-D /S .acl') DO ProcessACL.cmd "%%A"

which is finding all the files named ‘.acl’ in the current directory, or a subdirectory of the current directory.

The problem is, I’m finding path names that include the ‘&’ character (and no, they can’t be renamed), and I need a way of automatically escaping the ampersands and calling the second batch file with the escaped path as the parameter.

rem ProcessACL.cmd
echo %1
  • 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-05-17T23:17:27+00:00Added an answer on May 17, 2026 at 11:17 pm

    The problem is not the escaping, it seems to be in the second script.

    If there is a line like

    echo %1
    

    Then it is expands and fails:

    echo You & me.acl
    

    Better to use delayed expansion like

    setlocal EnableDelayedExpansion
    set "var=%~1"
    echo !var!
    

    To avoid also problems with exclamation points ! in the parameter, the first set should be used in a DisableDelayedExpansion context.

    setlocal DisableDelayedExpansion
    set "var=%~1"
    setlocal EnableDelayedExpansion
    echo !var!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realise that this is a very basic question, but it is one which
I've done numerous searches and I realize that I can just download this file
After reading E-myth Revisited, I realize that I can do a better job at
I just realised that Office 2007 now shows multiple pages per default. I can
I realise that the view/controller stuff will be different between Mac and IPhone apps
I realize that literally it translates to Java Enterprise Edition. But what I'm asking
I realize that this would be COMPLETELY bad practice in normal situations, but this
I realize that since UNIX sockets are platform-specific, there has to be some non-Java
I realize that parameterized SQL queries is the optimal way to sanitize user input
I realize that the query this question is looking for won't be enough to

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.