Search found 88 matches

by OJBakker
23 Mar 2024 03:24
Forum: DOS Batch Forum
Topic: if/elseif dont work like expected...Sorry, this time in English
Replies: 3
Views: 139

Re: if/elseif dont work like expected...Sorry, this time in English

if /I "%~1"=="/help" ( ECHO Ausgabe Hilfe cmd /k ) else if NOT exist "%~1" ( ECHO Datei existiert nicht^! Abbruch^! cmd /k ) else if /I "%~x1"=="" ( ECHO Keine DateiErweiterung^! Abbruch^! cmd /k ) else if /I NOT "%~x1"==".txt" ( ECHO DateiErweiterung ist nicht txt^! Abbruch^! cmd /k ) else if /I "...
by OJBakker
16 Mar 2024 15:11
Forum: DOS Batch Forum
Topic: Need Help: CALL subroutine in Batch dont worl like expected
Replies: 2
Views: 256

Re: Need Help: CALL subroutine in Batch dont worl like expected

You are using the first parameter supplied to your subroutine in your subroutine.
But in the main batchfile you are not calling the subroutine with a parameter.
by OJBakker
10 Nov 2023 15:31
Forum: DOS Batch Forum
Topic: ECHOing to a file without a trailing space
Replies: 6
Views: 18992

Re: ECHOing to a file without a trailing space

Place the redirect before the echo to avoid the trailing space in the echo command.

Code: Select all

>file0.tmp echo %field1%;%field2%;%field3%
by OJBakker
22 Oct 2023 02:02
Forum: DOS Batch Forum
Topic: [SOLVED] Validating user input against the content of a text file
Replies: 3
Views: 13388

Re: Validating user input against the content of a text file

Your code creates variable valid_disks with all valid disknumbers separated by spaces. You test for valid disknumber by checking if the entered disknumber with a leading and a trailing space is found in the valid_disk variable. The first disknumber in valid_disk will not have a leading space and the...
by OJBakker
13 Oct 2023 09:56
Forum: DOS Batch Forum
Topic: Variable inside an IF not showing correctly
Replies: 18
Views: 100159

Re: Variable inside an IF not showing correctly

You are halfway correct.
You have corrected the first "if not exist" but not the second one. There the errorlevel and errlev variables have to be corrected as well.
by OJBakker
13 Oct 2023 04:58
Forum: DOS Batch Forum
Topic: Variable inside an IF not showing correctly
Replies: 18
Views: 100159

Re: Variable inside an IF not showing correctly

Your problem is that you are using %errorlevel% in a () codeblock. Because of the codeblock %errorlevel% will give the value of the errorlevel special variable at the start of the codeblock and not the errorlevel as returned by xcopy or robocopy. Change the line echo %errorlevel% to echo !errorlevel...
by OJBakker
26 Sep 2023 11:42
Forum: DOS Batch Forum
Topic: :Concatenate function, advanced version, custom separator, multiple inputs, byval, byref and byref array ! (but oneprob)
Replies: 5
Views: 12839

Re: :Concatenate function, advanced version, custom separator, multiple inputs, byval, byref and byref array ! (but onep

I have attached 3 adapted versions of Concatenate-DEMO-For batch file. Your version uses a for /f loop to save over endlocal. The -For version is the shortest. It uses a for loop and for-param to save over endlocal. The -NoFor version uses no for but escapes the linefeeds before saving the param ove...
by OJBakker
24 Sep 2023 18:52
Forum: DOS Batch Forum
Topic: :ForIF Function, evaluates arguments like a IF inside a for (but there's strange behaviour ?)
Replies: 2
Views: 2890

Re: :ForIF Function, evaluates arguments like a IF inside a for (but there's strange behaviour ?)

You are using string-compare where you expect to do numerical-compare.

Examples:
if "2" LSS "10" (echo TRUE) else (echo FALSE)
False
explanation: "2 " > "10"

if "02" LSS "10" (echo TRUE) else (echo FALSE)
True

if 2 LSS 10 (echo TRUE) else (echo FALSE)
True
by OJBakker
24 Sep 2023 18:14
Forum: DOS Batch Forum
Topic: batchfile fails to delete unwanted files
Replies: 15
Views: 8870

Re: batchfile fails to delete unwanted files

Wow, what a mess you have created. :? :cry: You seem to be incapable of reading/following the most elementary instructions! By starting with running the corrected code from Batcher you yourself have deleted the bookmarkfiles! This confirms that your problem file had no permissions problem. An attrib...
by OJBakker
24 Sep 2023 08:01
Forum: DOS Batch Forum
Topic: batchfile fails to delete unwanted files
Replies: 15
Views: 8870

Re: batchfile fails to delete unwanted files

Yep, I am from the Netherlands and Dutch is my primary language so sometimes my English will have a 'touch of Dutch'. And my id at this forum is OJBakker, not OJBaker :lol: Your use of the term 'manually' is ambiguous. For you it apparently means: manually from the windows gui using windows explorer...
by OJBakker
23 Sep 2023 13:06
Forum: DOS Batch Forum
Topic: batchfile fails to delete unwanted files
Replies: 15
Views: 8870

Re: batchfile fails to delete unwanted files

The cause of your problem is most likely you are using the del command wrong. I have explained what goes wrong en how to prevent that from happening. The demo-code shows and explains this, with dir showing the selected files and del deleting these files and echo commenting on why some stuff fails. T...
by OJBakker
23 Sep 2023 04:38
Forum: DOS Batch Forum
Topic: batchfile fails to delete unwanted files
Replies: 15
Views: 8870

Re: batchfile fails to delete unwanted files

... I do not understand "I assume you are using a for loop to delete these files." In your first post you have posted no code and just one filename. In your last post you have posted one line of code. The code you have posted has no problem deleting a file with the filename you have posted. Because...
by OJBakker
22 Sep 2023 11:49
Forum: DOS Batch Forum
Topic: batchfile fails to delete unwanted files
Replies: 15
Views: 8870

Re: batchfile fails to delete unwanted files

I assume you are using a for loop to delete these files.
Something like the following will fail.

Code: Select all

for %%A in (bookmark*.jsonlz4) do del %%A
You can protect the filenames in the del command by enclosing the filename in double quote's.

Code: Select all

for %%A in (bookmark*.jsonlz4) do del "%%A"
by OJBakker
29 Aug 2023 12:25
Forum: DOS Batch Forum
Topic: Safer way to parse curl output?
Replies: 4
Views: 22408

Re: Safer way to parse curl output?

You can use the var search/replace syntax on the complete curl-response. @echo off cls setlocal set "CurlResp={"device_code":"f00b07aab09048268c78787c7f878787","user_code":"HFYRBFJF","verification_uri":"https://idcs-zzzzzzzzzzd.identity.cloud ... es_in":300}" rem find value for "device_code", value ...
by OJBakker
23 Aug 2023 01:07
Forum: DOS Batch Forum
Topic: avoid trailing space when piping to CLIP [SOLVED]
Replies: 6
Views: 4983

Re: avoid trailing space when piping to CLIP

Use double quotes in the set command:
SET/P "=TEXT" <nul | CLIP