This is feasible, but very complex to do as a batch script.
It'll be much easier for you to use a Windows port of the Unix touch program.
For example get touch.exe in the GnuWin32 project zip file:
https://sourceforge.net/projects/getgnuwin32/
Search found 227 matches
- 18 Mar 2024 08:51
- Forum: DOS Batch Forum
- Topic: How to truncate a file without updating its timestamp?
- Replies: 2
- Views: 5925
- 02 Mar 2024 11:13
- Forum: DOS Batch Forum
- Topic: Mouse Events are detected far less in a GOTO loop vs FOR /L loop
- Replies: 4
- Views: 9938
- 01 Mar 2024 10:13
- Forum: DOS Batch Forum
- Topic: How to wrap filename with blanks inside?
- Replies: 1
- Views: 5904
Re: How to wrap filename with blanks inside?
The problem is not the space, but the quotes you added around the pathname of the program. These quotes are indeed necessary because of the space. But when you add them, PowerShell stops considering this object as a reference to a program to execute, and considers it as a string object. To fix that,...
- 01 Mar 2024 09:54
- Forum: DOS Batch Forum
- Topic: Mouse Events are detected far less in a GOTO loop vs FOR /L loop
- Replies: 4
- Views: 9938
Re: Mouse Events are detected far less in a GOTO loop vs FOR /L loop
I was wondering if you guys had any idea what the difference between the two loops are, and why it would cause such a difference? We know that GOTO and CALL are implemented very inefficiently in the cmd.exe shell. There have been many discussions about this on this forum. To get the best performanc...
- 25 Feb 2024 11:56
- Forum: DOS Batch Forum
- Topic: Automating the generation of macros usable within other macros
- Replies: 4
- Views: 11150
Re: Automating the generation of macros usable within other macros
I went way too fast: There were two serious problems with the %%>, %%<, %%&, %%| definitions added in the previous set of macros! The versions generated with delayed expansion on and off were not identical. They worked when used in the same expansion mode they were defined in, but not when used in t...
- 18 Feb 2024 08:48
- Forum: DOS Batch Forum
- Topic: Automating the generation of macros usable within other macros
- Replies: 4
- Views: 11150
Re: Automating the generation of macros usable within other macros
To access the %-metavar you have to use the tilde %%~%% Yes, thanks, I found that yesterday too, but could not post an update as the Dostips server was unresponsive. Obviously the ~ forces the parser to skip phase 1.1, and enter phase 1.2 directly. Here's an updated set of macros integrating this. ...
- 16 Feb 2024 11:12
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 39478
Re: Macro for Dummies
Continuing the discussion about FOR! macros improvement in another thread Automating the generation of macros usable within other macros, as this is moving way off the original Macro for Dummies topic.
- 16 Feb 2024 09:51
- Forum: DOS Batch Forum
- Topic: Automating the generation of macros usable within other macros
- Replies: 4
- Views: 11150
Automating the generation of macros usable within other macros
I'm starting a new thread, because the discussion in Macro for Dummies is diverging way beyond the original subject. I've extended the four macros shown in post #15 in the above thread, to define four additional %%variables after 1 to 4 %expansions%: %%^> will generate a '>' character %%^< will gene...
- 13 Feb 2024 05:48
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 39478
Re: Macro for Dummies
OK, I got it at last: :# Define a %FOR!% macro, itself defining %%^^=^ and %%!=!, after one %expansion% for /f %%! in ("! =! ^^^!") do for /f %%1 in ("^ ^^^^ !!") do for %%~ in ("") do for %%+ in (%%1%%~~) do ^ set FOR%%!=for /f %%%%! in ^(^"%%! =%%! %%+%%+%%+%%!^"^) do for /f %%%%1%%1 in ^(^"%%1 %%...
- 13 Feb 2024 03:53
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 39478
Re: Macro for Dummies
I simply put them just behind, so %%^ expands to ^^!=! it automatically reduces to a single ^ Thanks for the tip, I should have tought of that :oops: I've easily fixed the FOR! macro using that technique, but I'm struggling to fix the other three. And (maybe related to my difficulties with the othe...
- 12 Feb 2024 09:45
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 39478
Re: Macro for Dummies
The rule for adding one more %expansion% depth level support is: 2x the 1st set of hats in %%^^ definition 4x the 2nd set of hats in %%^^ definition 4x+3 the set of hats in the %%! definition Which allows to simplify the second macro, and generate two more: :# Define a %FOR!% macro, itself defining ...
- 12 Feb 2024 05:39
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 39478
Re: Macro for Dummies
But independent of the usage of the %%! you need to handle also carets. This is precisely why this weekend I created the FOR! and FOR!! macros, used for building my WHILE and REPEAT macros. Having those exclamation and caret %%variables themselves defined in a macro makes it easier to reuse them al...
- 11 Feb 2024 12:51
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 39478
Re: Macro for Dummies
It's not possible to create a variable called " =".
What about doing this for really reducing the risk to 0?
Code: Select all
C:\JFL\Temp>set " ==1"
La syntaxe de la commande n’est pas correcte.
C:\JFL\Temp>set ==1
La syntaxe de la commande n’est pas correcte.
C:\JFL\Temp>
Code: Select all
for /f %%! in ("! =! ^^^!") do
- 11 Feb 2024 12:25
- Forum: DOS Batch Forum
- Topic: infinite loop with break condition
- Replies: 75
- Views: 159327
Re: infinite loop with break condition
I've been playing with these WHILE, REPEAT, and BREAK macros for a while, and came up with several significant improvements. First, it's relatively easy to avoid the need for a WEND macro following the WHILE macro, while still preserving the ability to nest WHILE and REPEAT loops. Unfortunately, tha...
- 11 Feb 2024 07:06
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 39478
Re: Macro for Dummies
Why is there a '^' before the second '!' in the %%! definition above?Code: Select all
for /f %%! in ("! ^! ^^^!")
I've run lots of tests without that '^', and never had any problem with that:
Code: Select all
for /f %%! in ("! ! ^^^!")