Search found 136 matches

by Eureka!
10 Oct 2024 09:52
Forum: DOS Batch Forum
Topic: how do i display empty lines with maybe DELIMS and TOKENS for TYPE command?
Replies: 6
Views: 12666

Re: how do i display empty lines with maybe DELIMS and TOKENS for TYPE command?

Or ...

Use FINDSTR with line numbering and work from there:

Code: Select all

T:\>findstr /n /r "^" f9.txt
1:1
2:2
3:3
4:
5:5
6:
7:7:5\;5:6
8:8
9:

T:\>for /f "usebackq tokens=1,* delims=:" %i in (`findstr /n /r "^" f9.txt`) Do @echo __%j__
__1__
__2__
__3__
____
__5__
____
__7:5\;5:6__
__8__
____

T:\>
by Eureka!
29 May 2023 12:26
Forum: DOS Batch Forum
Topic: How to clear an array?
Replies: 9
Views: 11045

Re: How to clear an array?

Aacini wrote:
29 May 2023 12:02
don't see any advantage in using your proposed notation to write arrays
It is *not* an array notation.
Maybe you understand better with

Code: Select all

set __somevar=abc
set __anothervar=123
by Eureka!
29 May 2023 07:26
Forum: DOS Batch Forum
Topic: How to clear an array?
Replies: 9
Views: 11045

Re: How to clear an array?

I think you are unrightfully critical ... I deliberately did ignore @ SIMMS7400's array variable structure to make it a more general solution. People who make use of array variables will have zero problems making the translation to adapt it to their situation. No need to explicitly specify that. Whe...
by Eureka!
28 May 2023 14:54
Forum: DOS Batch Forum
Topic: How to clear an array?
Replies: 9
Views: 11045

Re: How to clear an array?

Start your variables with some character-combination that you know does not exist elsewhere yet.
Example with "__" (that's what I use)

Defining:

Code: Select all

set __var1=abc
set __var2=123

Cleaning:

Code: Select all

for /f "usebackq tokens=1 delims==" %%x in (`set __`) do set "%%x="
by Eureka!
19 Apr 2022 16:29
Forum: DOS Batch Forum
Topic: open and pass multiple commands to other shell
Replies: 5
Views: 7182

Re: open and pass multiple commands to other shell

First: In my experience, it helps if you stay friendly. People here are willing to help and to spend their free time on *your* issue. Getting irritated likely scares them away. They are too skilled to waste their time on that. That out of the way: as I am not one of those skilled people, I will give...
by Eureka!
18 Apr 2022 13:20
Forum: DOS Batch Forum
Topic: ZeroKs 0 KB file compression
Replies: 8
Views: 11802

Re: ZeroKs 0 KB file compression

I'm afraid you don't understand that creating a file on disk requires allocating data to describe your file characteristics (pathname, create time, access rights, etc.). This is called "meta-data" about the file. Here, you're converting N KB of data to X*N KB of meta data, with X >> 1. So 1) You're...
by Eureka!
04 Feb 2022 18:32
Forum: DOS Batch Forum
Topic: Limitation in for /r command
Replies: 5
Views: 6081

Re: Limitation in for /r command

I ran into a similar issue here
Using that workaround here leads to:

Code: Select all

@echo off&setlocal

   for /d %%a in (*) do call :DEEPER "%%a"
goto :EOF


:DEEPER
   for /r %1 %%b in (*) do echo "%%b"  
goto :EOF
by Eureka!
04 Feb 2022 05:33
Forum: DOS Batch Forum
Topic: Difference .BAT / .CMD?
Replies: 4
Views: 5985

Re: Difference .BAT / .CMD?

Aacini wrote:
02 Feb 2022 14:04
You may review the commands described under Table 3 at this SO answer...
I did and .. thank you!


(and thanks for that quick date %date% admin-check too)
by Eureka!
02 Feb 2022 07:20
Forum: DOS Batch Forum
Topic: Difference .BAT / .CMD?
Replies: 4
Views: 5985

Difference .BAT / .CMD?

IIRC, there were some subtle differences between running a .CMD vs. running a .BAT script. I can't remember what those were at the moment and my forum-search skills are apparently lacking. Can someone help me get this straight? EDIT: To answer my own question (thanks, Google): The differences betwee...
by Eureka!
31 Jan 2022 15:42
Forum: DOS Batch Forum
Topic: search for previous item
Replies: 19
Views: 20331

Re: search for previous item

darioit wrote:
31 Jan 2022 04:45
Eureka! works fast and it's perfect for my purpose, thanks as always to all :D :D :D
You're welcome!

works fast
That makes me a bit curious: did you time this one too, @Squashman?
by Eureka!
30 Jan 2022 19:07
Forum: DOS Batch Forum
Topic: search for previous item
Replies: 19
Views: 20331

Re: search for previous item

Probably not the fastest one (didn't check), but for a different perspective. It *does* return all archives that contain the %search% pdf. @echo off set "file=filearchive2.txt" set "search=doc190049.pdf" findstr.exe /n /I /C:"#" /I /C:"%search%" "%file%" | sort.exe /r /o temp1.txt for /f "usebackq t...
by Eureka!
29 Jan 2022 16:47
Forum: DOS Batch Forum
Topic: Insert Text in Second Last Line of .xml
Replies: 6
Views: 6053

Re: Insert Text in Second Last Line of .xml

Does this work for you?

Code: Select all

findstr /v /i /c:"</menu>" "PC Games.xml" > temp.xml
by Eureka!
02 Dec 2021 17:40
Forum: DOS Batch Forum
Topic: Want to run on local machine as different user but seems that windows has limitations on running as different user on lo
Replies: 1
Views: 3397

Re: Want to run on local machine as different user but seems that windows has limitations on running as different user o

That is not how scheduled tasks work. When configuring a scheduled task, you also define the usercredentials that will be used to run the task (the Security options on the General tab). When you execute a command SCHTASKS /RUN .. , you need to "prove that you are worthy" to kick off that scheduled t...
by Eureka!
02 Oct 2021 18:16
Forum: DOS Batch Forum
Topic: How to get READONLY Status for Current disk drive (usb) - like diskpart/attr disk
Replies: 15
Views: 15954

Re: How to get READONLY Status for Current disk drive (usb) - like diskpart/attr disk

Code: Select all

@echo off & setlocal

for %%x in ("%__CD__%") do set "ThisVolume=%%~dx"

(
   echo sel vol %ThisVolume%
   echo attr disk
) | diskpart | ( findstr /i "Read-only  : No" >nul && echo Disk is not protected!)

   

That works because selecting a volume will implicitly select the right disk too.