Search found 14 matches

by Blazer
24 Nov 2019 03:37
Forum: DOS Batch Forum
Topic: single line in runonce
Replies: 4
Views: 4889

Re: single line in runonce

Try including the echo inside the brackets like this:

Code: Select all

for %%i in (A:,B:,D:,E:,F:,G:,H:,I:,J:,K:,L:,M:,N:,O:,P:,Q:,R:,S:,T:,U:,V:,W:,X:,Y:,Z:,) do (if exist %%i\autounattend.xml set usb=%%i & echo the usb drive is %usb%)
by Blazer
15 Jan 2019 03:56
Forum: DOS Batch Forum
Topic: Split text file at start marker and blank line or just start marker into multiple files
Replies: 9
Views: 7761

Re: Split text file at start marker and blank line or just start marker into multiple files

This is very simple to perform with JREPL.BAT :D Assuming the input file is indeed UTF-16 LE, and you want your output to be the same, then: jrepl "^(\d+) DIALOG" "$txt=$0; openOutput($1+'.rc',false,true);" /jq /utf /f dialog.rc The /jq option instructs that the 2nd argument is JScript code. The /u...
by Blazer
07 Jan 2019 03:20
Forum: DOS Batch Forum
Topic: Split text file at start marker and blank line or just start marker into multiple files
Replies: 9
Views: 7761

Re: Split text file at start marker and blank line or just start marker into multiple files

Don't rely on NP++. It can't handle UTF-16 (it doesn't even know of UTF-16). This was reported as bug way more than 10 years ago but the developers ignore it. Thus, they ignore the existence of languages like Japanese, Chinese and Korean on Windows. That's weird and the main reason why I once stopp...
by Blazer
06 Jan 2019 06:47
Forum: DOS Batch Forum
Topic: Split text file at start marker and blank line or just start marker into multiple files
Replies: 9
Views: 7761

Re: Split text file at start marker and blank line or just start marker into multiple files

@aGerman @Aacini Thank you, both solutions create the individual files but they contain garbage characters :( I assume this is because the input file is unicode, Notepad++ reports it has "UCS-2 LE BOM" encoding I tried changing the following section of code < Dialog.rc ( to type Dialog.rc ^|( but th...
by Blazer
05 Jan 2019 06:44
Forum: DOS Batch Forum
Topic: Split text file at start marker and blank line or just start marker into multiple files
Replies: 9
Views: 7761

Split text file at start marker and blank line or just start marker into multiple files

I am trying to decide the best way of splitting the following single .rc file into mutiple files. The start of each split are the lines where the first column is a number and the second column begins with the word DIALOG The end of each split should be either a blank line or another start line (in c...
by Blazer
02 Jan 2019 05:22
Forum: DOS Batch Forum
Topic: Delete substring using variable inside for /f
Replies: 7
Views: 5805

Re: Delete substring using variable inside for /f

This problem has been solved by both @aGerman and @Squashman :)

But I wonder if its possible to tweak the solution from @Squashman so that it works without the call statement?

Call Set "_dummy=%%_cities:!_substr!=%%"

Thank you
by Blazer
02 Jan 2019 05:02
Forum: DOS Batch Forum
Topic: For /f processing delimited string
Replies: 4
Views: 4689

Re: For /f processing delimited string

@Aacini

Thank you, your batch-fu is strong 8)
by Blazer
26 Dec 2018 07:23
Forum: DOS Batch Forum
Topic: For /f processing delimited string
Replies: 4
Views: 4689

Re: For /f processing delimited string

@IcarusLives

Thanks for your help. 8)
by Blazer
25 Dec 2018 07:28
Forum: DOS Batch Forum
Topic: For /f processing delimited string
Replies: 4
Views: 4689

For /f processing delimited string

for /f "delims=?" %A in ("123?456?789") do echo %A

This runs the loop once and sets %A to 123

I want it to loop for each substring based on the delimiter so that I can run a number of commands on %A

Loop 1 %A = 123
Loop 2 %A = 456
Loop 3 %A = 789

Thank you
by Blazer
25 Dec 2018 06:20
Forum: DOS Batch Forum
Topic: Delete substring using variable inside for /f
Replies: 7
Views: 5805

Re: Delete substring using variable inside for /f

@aGerman
@Squashman

Thank you for your help :D
by Blazer
23 Dec 2018 05:28
Forum: DOS Batch Forum
Topic: Delete substring using variable inside for /f
Replies: 7
Views: 5805

Re: Delete substring using variable inside for /f

That does work but I was hoping to find a way to fix the existing code without adding another for loop.

Maybe some extra exclamation or percent characters.

Thanks.
by Blazer
21 Dec 2018 03:22
Forum: DOS Batch Forum
Topic: Delete substring using variable inside for /f
Replies: 7
Views: 5805

Re: Delete substring using variable inside for /f

Thank you for your input Steffen, unfortunately that does not work :( Here is the new code: @Echo off for /f "delims=" %%F in ('dir /b "C:\Windows"') do ( Setlocal EnableDelayedExpansion Set _cities="Aberdeen, London, Edinburgh" Set _substr=Rome Set _dummy=!_cities:%_substr%=! Echo !_dummy! If Not "...
by Blazer
20 Dec 2018 10:26
Forum: DOS Batch Forum
Topic: Delete substring using variable inside for /f
Replies: 7
Views: 5805

Delete substring using variable inside for /f

I am trying to delete a substring from a variable using another variable inside a for /f loop. The "Setlocal EnableDelayedExpansion" is required for other code. The following example does not work. Please help. Thank you. @Echo off for /f "delims=" %%F in ('dir /b "C:\Windows"') do ( Setlocal Enable...