1

What I'm trying to achieve is to take a user input which would be a term with numbers and letters and then use that to match directories in a folder and delete ones matching, here's what i have till now, but its not working,

@echo off
set /p:ID=Enter Search Term:
for /d %%G in ("*(%ID%)") do rd /s /q "%%~G"
pause

The output that i get if i turn on echo shows, that %ID% is not getting replaced with variable value which was the prompted input. Following is the output

for / %G in ("*()") do rd /s /q "%~G"

Can someone point out the error in this? thanks a lot

2
  • 1
    What's your error output? Commented Aug 31, 2015 at 11:50
  • i've edited the question with the output for reference, thanks Commented Aug 31, 2015 at 12:24

1 Answer 1

4
set /p:ID=Enter Search Term:
      ^ This colon is included in the name of the variable

So, you end with a variable named :ID. You can execute set : to see the variable defined.

To solve the problem just remove the colon.

set /p ID=Enter Search Term:
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.