![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
Hi,
I've enabled "delayed environment variable expansion". How can I use an exclamaton mark in filenames in my batch files? Regards, Piotr |
Ads |
#2
|
|||
|
|||
![]()
Uhh? Why do you want to? Use ! instead of %.
--=20 ---------------------------------------------------------- "Piotr" wrote in message = ... Hi, =20 I've enabled "delayed environment variable expansion". How can I use = an=20 exclamaton mark in filenames in my batch files? =20 Regards, =20 Piotr |
#3
|
|||
|
|||
![]()
Uhh? Why do you want to? Use ! instead of %.
I need delayed environment variable expansion. And I want to use cmd.exe not bash ![]() Regards, Piotr |
#4
|
|||
|
|||
![]() "Piotr" wrote in message ... Hi, I've enabled "delayed environment variable expansion". How can I use an exclamaton mark in filenames in my batch files? Regards, Piotr Trial and error shows that this works: @echo off echo. !b!.txt setlocal enabledelayedexpansion for /L %%a in (1,1,9) do ( set b=%%a echo a=%%a, b=!b! dir /b "^!b^!.txt" ) |
#5
|
|||
|
|||
![]()
Use ! instead of %
--=20 ---------------------------------------------------------- "Piotr" wrote in message = ... Uhh? Why do you want to? Use ! instead of %. =20 I need delayed environment variable expansion. =20 And I want to use cmd.exe not bash ![]() =20 Regards, =20 Piotr |
#6
|
|||
|
|||
![]()
Trial and error shows that this works:
Why not manual??? ![]() dir /b "^!b^!.txt" Thanks. It works. I've not imagined that there had to be *both* quotations marks and ^ (eg "^!")... Thanks once again Piotr |
#7
|
|||
|
|||
![]() "Piotr" wrote in message ... Trial and error shows that this works: Why not manual??? ![]() Because batch file language is not a nice and tightly defined programming language. It's full of little and unexpected surprises, and as many frustrations and disappointments. dir /b "^!b^!.txt" Thanks. It works. I've not imagined that there had to be *both* quotations marks and ^ (eg "^!")... Thanks once again Piotr |
#8
|
|||
|
|||
![]()
Use ! instead of %
Either I don't understand what you mean, or you don't understand me. Maybe both ![]() But Pegasus (MVP) gave me an answer. The problem is - I run cmd.exe with "delayed environment variable expansion" (DEVE). And I need to use files/directories with an exclamation mark in theirs names. For example: @echo off mkdir !info dir Z:\ /s /b !info/!CD.txt And don't ask me why I need DEVE ![]() Regards, Piotr |
#9
|
|||
|
|||
![]()
It sounds like your problem was quoting filenames. You would have had =
the same problem with %. So your question had nothing to do with DEVE. = So don't waste people's time here with delibrate misinformatrion ******. --=20 ---------------------------------------------------------- "Piotr" wrote in message = ... Use ! instead of % =20 Either I don't understand what you mean, or you don't understand me. = Maybe=20 both ![]() =20 But Pegasus (MVP) gave me an answer. =20 The problem is - I run cmd.exe with "delayed environment variable = expansion"=20 (DEVE). And I need to use files/directories with an exclamation mark = in=20 theirs names. For example: =20 @echo off mkdir !info dir Z:\ /s /b !info/!CD.txt =20 And don't ask me why I need DEVE ![]() =20 Regards, =20 Piotr |
#10
|
|||
|
|||
![]()
Why not manual???
![]() Because batch file language is not a nice and tightly defined programming language. It's full of little and unexpected surprises, and as many frustrations and disappointments. But since Microsoft is still making changes to it maybe there is a future ![]() Why do I have to use VBS just to make some backups, compress some files and so on. I'm using batches for 15 years and I like them ![]() Piotr |
#11
|
|||
|
|||
![]() "Piotr" wrote in message ... Why not manual??? ![]() Because batch file language is not a nice and tightly defined programming language. It's full of little and unexpected surprises, and as many frustrations and disappointments. But since Microsoft is still making changes to it maybe there is a future ![]() Why do I have to use VBS just to make some backups, compress some files and so on. I'm using batches for 15 years and I like them ![]() Piotr I did not say that you have to use VBS. I only replied to your question about the documentation for this particular syntax. There isn't any, and I don't think there will ever be. If you wish to do something special in a batch file, try it. If it works - great!, but don't expect it to be as robust as in a programming language. I don't think, for example, that anyone has ever tried to explain why the "call" command is necessary in the following sample code, and why it works, but it does! @echo off set variable=abcdefg set string1=cde set string2=xyz call set variable=%%variable:%string1%=%string2%%% echo Var=%variable% Now consider how string substitution is done in a programming language, then shake your head in amazement about this extraordinary piece of code. |
#12
|
|||
|
|||
![]()
It sounds like your problem was quoting filenames. You would
have had the same problem with %. So your question had nothing to do with DEVE. So don't waste people's time here with delibrate misinformatrion ******. LOL... Really... No, my problem wasn't quoting filenames (why I had to put ^ before ! *and* had to quote it?) No, I wouldn't have had the same problem with % - I just place two %% which is translated to one %... (it was working for ages - since DOS 3.30 fore sure ![]() Yes, my question *does* have something with DEVE - my batches stopped working just after I had turned on DEVE... Why? Bad current voltage? ![]() No, I do *not* waste people's time. Do you? Regards Piotr |
#13
|
|||
|
|||
![]()
OK, you are right. Batch file language *is* full of bugs, I mean *features*
![]() Maybe call makes cmd to run subshell? I've never tried to use call but to run another batch file... Wow ![]() Piotr |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Exclamation mark | Barbara | General XP issues or comments | 7 | February 12th 05 09:06 PM |