Search found 4035 matches

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

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: 3
Views: 81

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: 3
Views: 81

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

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

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

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

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

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

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.)
by aGerman
16 Jul 2021 10:24
Forum: DOS Batch Forum
Topic: [How-To] Screenshot of Batch window (PowerShell hybrid)
Replies: 4
Views: 247

Re: [How-To] Screenshot of Batch window (PowerShell hybrid)

jfl wrote:
16 Jul 2021 10:14
it captures it as HTML with colors
That's awesome 😮 Thanks for sharing Jean-François!

Steffen
by aGerman
16 Jul 2021 03:23
Forum: DOS Batch Forum
Topic: FOR /F with usebackq usage
Replies: 1
Views: 124

Re: FOR /F with usebackq usage

The only relevant use case for USEBACKQ that I'm aware of is if you have to process the content of files. File names with spaces and special characters have to be surrounded with double quotes. (And it's best practice anyway to quote them.)

Steffen
by aGerman
15 Jul 2021 14:39
Forum: DOS Batch Forum
Topic: Find specificly named folder and make that as current repo
Replies: 10
Views: 188

Re: Find specificly named folder and make that as current repo

set "folder=" for %%a in (C D E F) do if not defined folder ( for /f "tokens=*" %%i in ('robocopy "%%a:\." " nul" "LeagueClient.exe" /xd "C:\Windows" /l /s /xx /r:1 /w:1 /ns /nc /ndl /np /njh /njs') do set "folder=%%~dpi" ) if defined folder %comspec% /k cd /d "%folder%" The path in %folder% has a ...
by aGerman
15 Jul 2021 14:05
Forum: DOS Batch Forum
Topic: Find specificly named folder and make that as current repo
Replies: 10
Views: 188

Re: Find specificly named folder and make that as current repo

You can parse the output of ROBOCOPY. It's known to use multi-threading and you have the possibility to effectively exclude folders. The example below excludes C:\Windows. But that's all I can think of. And I don't believe that it can be significantly improved. Compare it with how long it takes to f...
by aGerman
15 Jul 2021 13:35
Forum: DOS Batch Forum
Topic: Find specificly named folder and make that as current repo
Replies: 10
Views: 188

Re: Find specificly named folder and make that as current repo

Code: Select all

set "file="
for %%a in (C D E F) do if not defined file (
  for /f "delims=" %%b in ('2^>nul where /r "%%a:\\" "LeagueClient.exe"') do set "file=%%b"
)
echo "%file%"
That's about 10% faster on my machine. However, it still takes ages :lol:

Steffen
by aGerman
15 Jul 2021 12:21
Forum: DOS Batch Forum
Topic: Find specificly named folder and make that as current repo
Replies: 10
Views: 188

Re: Find specificly named folder and make that as current repo

I mean, what do you expect if you're running through the whole C: drive? Explore your user profile, or the Programs folder, or the Windows folder. The sheer amount of subfolders and depth of the folder trees is overwhelming. There might be a possibility to use the WHERE command if you would specify ...