Search found 13 matches

by OJBakker
2023-Dec-06, 9:42 pm
Forum: Windows CMD Shell
Topic: file not erased
Replies: 7
Views: 2965

Re: file not erased

The dir shows your code is doing what you tell it to do.
There is no file or directory with the name "jupe tututeen" (filename without extension).
So the if returns false and the del is skipped.
by OJBakker
2023-Dec-06, 5:04 pm
Forum: Windows CMD Shell
Topic: file not erased
Replies: 7
Views: 2965

Re: file not erased

Ok, I see what i have missed in your code. You are using the "delims=." as an unreliable method to split the filename and the extension. The dir selects the file "jupe tututeen.mp4". The if exist might work but only if "jupe tututeen" exists as file or directory. The de...
by OJBakker
2023-Dec-05, 6:50 pm
Forum: Windows CMD Shell
Topic: file not erased
Replies: 7
Views: 2965

Re: file not erased

problems: You post test.cmd this suggests you refer to a batchfile. Then you post code, not for a batchfile but for commandline. Then you post a supposed result of your code that can not be the result of the code you posted. The code you posted with the file "jupe tututeen.mkv" will result...
by OJBakker
2023-Dec-02, 9:33 am
Forum: Windows CMD Shell
Topic: FOR loop : make it stop itself
Replies: 2
Views: 3056

Re: FOR loop : make it stop itself

This will echo just the first result found.
It will not stop processing the entire file.

Code: Select all

set "found=" & FOR /f "tokens=4,5" %i in (file.txt) DO @if not defined found if "%j" == "sometext" echo %i %j & set "found=1"
by OJBakker
2023-Aug-09, 2:58 pm
Forum: Windows CMD Shell
Topic: FOR /F with multiple commands
Replies: 1
Views: 9409

Re: FOR /F with multiple commands

Yes, but you need to correct syntax errors to do this, especially escape the pipe symbol.

Code: Select all

for /f tokens^=* %%a in ('dir ^| more') do echo %%a
or

Code: Select all

for /f "tokens=*" %%a in ('dir ^| more') do echo %%a
by OJBakker
2023-Aug-03, 6:20 pm
Forum: Windows CMD Shell
Topic: For /F - Tokens has me puzzled
Replies: 6
Views: 10231

Re: For /F - Tokens has me puzzled

:) The order can be ascending, descending or random, but that is not really important. The reason I used descending so it is clear the asterix and the token it creates is not related to the last token-number before the asterix in the string. In testscript I often use the form of echo [%%A] [%%B] [%%...
by OJBakker
2023-Aug-03, 4:08 pm
Forum: Windows CMD Shell
Topic: For /F - Tokens has me puzzled
Replies: 6
Views: 10231

Re: For /F - Tokens has me puzzled

Nice, may I suggest a few additions / changes? If an asterix is used in the token = string then it must be the last character in the string. If the last character in the tokens= string is an asterisk, then one additional parameter is added for all the remaining text on the line. The parameter added ...
by OJBakker
2023-Aug-02, 1:41 pm
Forum: Windows CMD Shell
Topic: For /F - Tokens has me puzzled
Replies: 6
Views: 10231

Re: For /F - Tokens has me puzzled

From the for/f page: tokens=* will cause all items on each line to be processed. tokens=3* will process the third token and the 4th + all subsequent items, this can also be written as tokens=3,* Each token specified will cause a corresponding parameter letter to be allocated. The letters used for to...
by OJBakker
2023-Jul-23, 2:31 pm
Forum: Windows CMD Shell
Topic: Does "endlocal" close all instances of "setlocal"?
Replies: 6
Views: 10424

Re: Does "endlocal" close all instances of "setlocal"?

Just add a few lines to your script and the answer is obvious. Try the script below. setlocal enabledelayedexpansion enableextensions set name1=1 setlocal disabledelayedexpansion enableextensions set name2=2 setlocal enabledelayedexpansion enableextensions set name3=3 set name endlocal set name endl...
by OJBakker
2023-Mar-15, 4:39 pm
Forum: Windows CMD Shell
Topic: Are there any scripts that DEPEND on NOT using Delayed Expansion?
Replies: 6
Views: 6641

Re: Are there any scripts that DEPEND on NOT using Delayed Expansion?

Try this: @echo off setlocal disabledelayedexpansion echo disabled delayedexpansion set test=hello! set test set "test=hello!" set test endlocal setlocal enabledelayedexpansion echo enabled delayedexpansion set test=hello! set test set "test=hello!" set test set "test=hello^...