Search found 4041 matches

by aGerman
26 Jul 2021 14:47
Forum: DOS Batch Forum
Topic: Shorten file names with REN
Replies: 2
Views: 39

Re: Shorten file names with REN

Tokenize the file names in a FOR /F loop.

Code: Select all

pushd "C:\your\folder"
for /f "tokens=1* delims=-" %%i in ('dir /a-d /b "Listing-*.txt"') do ren "%%i-%%j" "L%%j"
popd
Steffen
by aGerman
26 Jul 2021 14:15
Forum: DOS Batch Forum
Topic: Fastest Recursive Searching
Replies: 15
Views: 163

Re: Fastest Recursive Searching

I refrain from asking you how you got it bloated that much :lol: FWIW I'm a little amazed that defining the source with a trailing space still works :o I mean, it's a known issue that "%programfiles%\" failes because robocopy uses the default C tokenizing for the command line. The backslash escapes ...
by aGerman
26 Jul 2021 13:47
Forum: DOS Batch Forum
Topic: Fastest Recursive Searching
Replies: 15
Views: 163

Re: Fastest Recursive Searching

Then it's probably still searching in the remaining folder structures. Maybe C:\Users (which is only 7.6 GB here).
by aGerman
26 Jul 2021 13:30
Forum: DOS Batch Forum
Topic: Fastest Recursive Searching
Replies: 15
Views: 163

Re: Fastest Recursive Searching

That's weird :shock: Too many threads already? :lol: What if you remove the 64 from the list?
by aGerman
26 Jul 2021 12:56
Forum: DOS Batch Forum
Topic: Fastest Recursive Searching
Replies: 15
Views: 163

Re: Fastest Recursive Searching

@echo off &setlocal EnableDelayedExpansion for %%n in (64 %NUMBER_OF_PROCESSORS% 2) do ( echo /mt:%%n echo !time! for /f "tokens=*" %%i in ( 'robocopy "C:\." " nul" "wordpad.exe" /xd "C:\Windows" /l /s /mt:%%n /xx /r:1 /w:1 /ns /nc /ndl /np /njh /njs' ) do echo "%%i" echo !time! echo ~~~~~~~~~~~~~~...
by aGerman
26 Jul 2021 10:50
Forum: DOS Batch Forum
Topic: Fastest Recursive Searching
Replies: 15
Views: 163

Re: Fastest Recursive Searching

Your CPU must have been quite bored before :lol:
If you run the /MT:32 before /MT:8, is it still faster? (Beware of caching :wink:)

Steffen
by aGerman
25 Jul 2021 10:25
Forum: DOS Batch Forum
Topic: CONVERTCP.exe - Convert text from one code page to another
Replies: 130
Views: 121469

Re: CONVERTCP.exe - Convert text from one code page to another

Version 8.2 is a minor update. It adds the opportunity to overwrite the original file with the converted content. Pass a single minus sign along with option /o to specify it. The minus sign is only taken as wildcard for the same file name under the following assumptions: - option /i is specified - o...
by aGerman
24 Jul 2021 06:31
Forum: DOS Batch Forum
Topic: Fastest Recursive Searching
Replies: 15
Views: 163

Re: Fastest Recursive Searching

The number of threads defaults to 8 if you don't specify the /MT option. Keep in mind that multithreading is not for free. There is a break-even. Rule of thumb is to use as many threads as the number of logical cores on your machine. There's a predefined variable you might want to take instead. /MT:...
by aGerman
23 Jul 2021 14:20
Forum: DOS Batch Forum
Topic: Fastest Recursive Searching
Replies: 15
Views: 163

Re: Fastest Recursive Searching

https://www.dostips.com/forum/viewtopic.php?f=3&t=10140 Turns out that robocopy works nicely because it supports the exclusion of heavy folders like C:\Windows, at least if you have to begin searching in the root folder of a drive. It can also be used if you only have a few locations where you expec...
by aGerman
22 Jul 2021 15:39
Forum: DOS Batch Forum
Topic: Search for file content in a folder
Replies: 1
Views: 75

Re: Search for file content in a folder

Code: Select all

for /f "delims=" %%i in ('forfiles /p "C:\your\folder" /d +0 /c "cmd /c if @isdir==FALSE findstr /mc:0x22your search string0x22 @path"') do echo "%%i"
Note that FINDSTR won't find anything in files containig other data than plain text.

Steffen
by aGerman
21 Jul 2021 13:46
Forum: DOS Batch Forum
Topic: Parenthetical Redirection
Replies: 7
Views: 126

Re: Parenthetical Redirection

Recently I wrote some tips for best practice. https://www.dostips.com/forum/viewtopic.php?f=3&t=10137 So, you may enable delayed variable expansion right before you redirect the strings. (And maybe disable it after that, in case that more code is following.) This has not necessarily something to do ...
by aGerman
20 Jul 2021 11:47
Forum: DOS Batch Forum
Topic: Batch random number through C executable
Replies: 4
Views: 173

Re: Batch random number through C executable

While I agree with Squashman that this is not a C forum, just as an aside: Don't use the standard C functions to generate pseudorandom numbers. The generated values of rand() are as predictable as the values of the %random% variable. If you want to have a C-like functionality on Windows, rather use ...
by aGerman
19 Jul 2021 10:48
Forum: DOS Batch Forum
Topic: Filter DIR by Date and Time?
Replies: 3
Views: 125

Re: Filter DIR by Date and Time?

WMIC can do this if you really need to involve the time rather than only the date. for /f "delims=" %%i in ('wmic datafile WHERE "Drive='C:' AND Path='\\whatever\\path\\it\\is\\'" GET LastModified^,Name^|findstr /b "[0-9]"') do ( for /f "tokens=1,2* delims=. " %%j in ("%%i") do if "%%j" gtr "2021071...
by aGerman
18 Jul 2021 07:03
Forum: DOS Batch Forum
Topic: CmdBkg - use bitmap as background to console window
Replies: 76
Views: 42012

Re: CmdBkg - use bitmap as background to console window

A few weeks ago I had an idea of how to overcome the issue explained above. There's an undocumented API for an acrylic (blurred) background. So, rather than making the console window transparent we could optionally use this effect. That feature is not downward compatible though. As to the little I'v...
by aGerman
17 Jul 2021 17:21
Forum: DOS Batch Forum
Topic: Command line to write registry keys bypassing any prompt
Replies: 7
Views: 2245

Re: Command line to write registry keys bypassing any prompt

Registry keys which require elevation can't be updated without admin privileges.

Steffen

(Stop promoting your site in each and every post! Otherwise, I'll ban your account.)