Search found 4033 matches

by aGerman
23 Jul 2021 14:20
Forum: DOS Batch Forum
Topic: Fastest Recursive Searching
Replies: 2
Views: 30

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

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

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

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

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

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

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

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

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

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

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

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

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 ...
by aGerman
15 Jul 2021 10:21
Forum: DOS Batch Forum
Topic: Find specificly named folder and make that as current repo
Replies: 10
Views: 167

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

Wildcards are only supported in the last element of a path. However, globbing means that all folders that meet the pattern will be found and you need an additional comparison to be sure you found the folder you're looking for. You should be aware that recursively running through the drives will take...
by aGerman
15 Jul 2021 07:28
Forum: DOS Batch Forum
Topic: [How-To] Screenshot of Batch window (PowerShell hybrid)
Replies: 4
Views: 236

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

Thanks for your feedback! I'm not sure if the macro is particularly useful. Likely only for a few people. However, it shows how to take a screenshot from within a script, which can easily be reused for similar macro codes. All you need are virtual screen coordinates of the rectangle you want to capt...