Search found 116 matches
- 23 Jan 2021 19:45
- Forum: DOS Batch Forum
- Topic: Request for help to speed up batch program for 17,000 TXT files
- Replies: 2
- Views: 30
Re: Request for help to speed up batch program for 17,000 TXT files
rem Write each remaining word >=4 characters as lowercase on a new line call jrepl "\S{4,}" "$txt=$0.toLowerCase()" /jmatchq /f "%%F" /o - rem Reduce to sorted list of unique words sort /unique "%%F" /o "%%F" It might be more efficient to *not* convert the words to lowercase, as this SORT command i...
- 23 Jan 2021 19:20
- Forum: DOS Batch Forum
- Topic: SORT supports the /UNIQUE option!
- Replies: 5
- Views: 25
Re: SORT supports the /UNIQUE option!
There was. This was the first time I heard about it (thanks to @penpen), but undoubtedly there were earlier mentions of it.ShadowThief wrote: ↑23 Jan 2021 14:18I could have sworn that we already had a thread about this and I learned about it from that.
- 30 Dec 2020 14:29
- Forum: DOS Batch Forum
- Topic: Equivalent 9XDos code to NT Find bat/cmd path %~dp0
- Replies: 12
- Views: 737
Re: Equivalent 9XDos code to NT Find bat/cmd path %~dp0
maybe the TRUENAME command can help you here.
Something like: TRUENAME %0 or even TRUENAME %0\..
(but memory is vague; maybe truename wasn't even in Win98)
Something like: TRUENAME %0 or even TRUENAME %0\..
(but memory is vague; maybe truename wasn't even in Win98)
- 28 Dec 2020 08:40
- Forum: DOS Batch Forum
- Topic: Pass a comand on a batch with admin privileges
- Replies: 4
- Views: 530
Re: Pass a comand on a batch with admin privileges
Do you have any code that doesn't require adding registry keys? What is wrong with adding registry keys? (they are removed too, btw) I just want to ask for elevation and pass a parameter, this way it can be autostart from a rar sfx... That is what this script does! I edited the original code a litt...
- 27 Dec 2020 05:24
- Forum: DOS Batch Forum
- Topic: Pass a comand on a batch with admin privileges
- Replies: 4
- Views: 530
Re: Pass a comand on a batch with admin privileges
Start DEMO.cmd with some parameters, like DEMO a b c d DEMO.cmd @echo off setlocal :: Check if elevated; restart as elevated admin if not. whoami.exe /groups|findstr /i /c:"S-1-5-32-544" > nul || goto :NEEDADMIN REM Your code here echo This is elevated code echo Demo : current (elevated) commandline...
- 22 Nov 2020 15:03
- Forum: DOS Batch Forum
- Topic: Detecting and removing TABs from a string without prior access to the TAB character
- Replies: 14
- Views: 1407
Re: Detecting and removing TABs from a string without prior access to the TAB character
You're welcome! (FWIW: another alternative if you have delayedexpansion already enabled) @echo off setlocal enabledelayedexpansion set STRING=abc def ghi.txt set TEMPSTRING=%STRING: =% for /f %%x in ("%TEMPSTRING%") do set NOT=%%~x set REST=!TEMPSTRING:%NOT%=! set TAB=%REST:~0,1% echo NEWSTRING=!STR...
- 22 Nov 2020 12:50
- Forum: DOS Batch Forum
- Topic: Detecting and removing TABs from a string without prior access to the TAB character
- Replies: 14
- Views: 1407
Re: Detecting and removing TABs from a string without prior access to the TAB character
Basic concept (with comments for clarity) @echo off setlocal :: abc[space][space]def[tab]ghi.txt set STRING=abc def ghi.txt :: Strip spaces set TEMPSTRING=%STRING: =% :: Get first "word" before TAB for /f %%x in ("%TEMPSTRING%") do set NOT=%%~x :: Use all characters of first word as delimiter :: so ...
- 18 Nov 2020 10:30
- Forum: DOS Batch Forum
- Topic: About variable expansion
- Replies: 8
- Views: 1332
Re: About variable expansion
If your string doesn't contain spaces ( it looks that way, based on your demo string ), you can also do something like this: @echo off setlocal enabledelayedexpansion set string=120400082_V1_UTR_HN512_gfhtgnnrt for /L %%i in (0,1,9) DO set STRING=!STRING:%%i= ! if "%STRING:~0,1%" EQU " " set PRE=* i...
- 14 Nov 2020 11:57
- Forum: DOS Batch Forum
- Topic: how to pick up the duplicated files only from the greatest versions
- Replies: 4
- Views: 1019
Re: how to pick up the duplicated files only from the greatest versions
My bad! I accidentally added the /R option to the wrong sort (my original version worked fine).
Code and output above are updated.
Code and output above are updated.
- 13 Nov 2020 19:15
- Forum: DOS Batch Forum
- Topic: how to pick up the duplicated files only from the greatest versions
- Replies: 4
- Views: 1019
Re: how to pick up the duplicated files only from the greatest versions
Assuming the structure of the part before the "\" is always the same (\Tnnn-nnnnn-nnnn\) : (and assuming your list is in mockup.lst) @echo off setlocal enabledelayedexpansion for /f "usebackq delims=" %%I in (`sort mockup.lst ^| sort /R /+17`) do ( if /i "!PREVIOUS!" NEQ "%%~nI" ( echo %%I>> after.t...
- 08 Nov 2020 15:12
- Forum: DOS Batch Forum
- Topic: batch file PID
- Replies: 6
- Views: 1320
Re: batch file PID
Alternative: for /f "tokens=2 delims==" %%i in ( 'wmic process WHERE ^"CommandLine LIKE '%comspec:\=\\% /c wmic process WHERE \^"CommandLine LIKE%%'^" get ParentProcessId /value' ) do set "PID=%%i" (based on this thread ) EDIT: Never mind; a similar solution was already mentioned in one of the linke...
- 30 Oct 2020 08:38
- Forum: DOS Batch Forum
- Topic: Detect when a batch file crashes or closes unexpectedly?
- Replies: 6
- Views: 1404
- 28 Oct 2020 18:25
- Forum: DOS Batch Forum
- Topic: Detect when a batch file crashes or closes unexpectedly?
- Replies: 6
- Views: 1404
Re: Detect when a batch file crashes or closes unexpectedly?
I probably missed or misinterpreted some clues here, but shouldn't this be enough? : @echo off setlocal If /i [%1] == [APE] goto :APE ::__________________________________ :: :: WATCHDOG ::__________________________________ :: TITLE Do not close this!! Echo this is the watchdog routine. Don't close t...
- 27 Oct 2020 18:37
- Forum: DOS Batch Forum
- Topic: batch file to spam a removable drive with partitions?
- Replies: 2
- Views: 1031
Re: batch file to spam a removable drive with partitions?
You forgot to create a VOLUME in your diskpart script 

- 06 Sep 2020 08:12
- Forum: DOS Batch Forum
- Topic: FOR doesn't iterate properly
- Replies: 4
- Views: 1351
Re: FOR doesn't iterate properly
Take a look at the explanation of delayed environment variable expansion (command: SET /?) CMD reads FOR ... ( ...) as a single line and all variables will be expanded all at once when reading that entire line. Example: This will only echo the same time multiple times (= the time when the command wa...