Search found 90 matches

by OJBakker
25 Aug 2024 12:19
Forum: DOS Batch Forum
Topic: Batch file question
Replies: 2
Views: 30199

Re: Batch file question

Your batchfile does what you tell it to do. By using only the drive specifier and not specifying the directory on that drive you are saying use the current direcory on the sourcedrive and the current directory on the destination drive. That is not what you intended but it is how it works. Flexibilit...
by OJBakker
29 Apr 2024 08:13
Forum: DOS Batch Forum
Topic: Need help with misbehaving DOS code
Replies: 2
Views: 7589

Re: Need help with misbehaving DOS code

The timeout command is never reached in your code. You end your code with the 'goto :eof' line which stops the processing. You can add a label before the timeout-command and change the goto :eof to jump to this new label. Or move the timeout-command to within the if-command so the timeout will be ex...
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: 7324

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: 5500

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: 25503

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: 16977

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: 115570

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: 115570

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: 17341

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: 5103

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: 17569

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: 17569

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: 17569

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: 17569

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: 17569

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"