Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 8937

Windows Batch For Loop Filenames with Exclamation Point "!" Problems

$
0
0

Exclamation Points are my bane with Windows Batch. Say I want to just skip filenames with an ! in them.

I know for checking regular text in variables in a for loop, I can run:

setlocal enabledelayedexpansionfor /r %%a in (*) do (set fname=%%~naif not "!fname!"=="!fname:text=!" ECHO File contains the word "text")

But how do I specify an exclamation point?

I've tried to escape it with ^: "!fname:^!=!"

Then I see that with enabledelayedexpansion you need a ^^! to escape the character. So I tried that with no luck. Then I thought maybe three ^^^! two to escape delayedexpansion and one in the filename...

No luck...

Any suggestions?


Viewing all articles
Browse latest Browse all 8937

Trending Articles