Search found 3737 matches

by aGerman
24 May 2020 04:39
Forum: DOS Batch Forum
Topic: Create random folders and move files in them
Replies: 3
Views: 462

Re: Create random folders and move files in them

That's not tested at all. @echo off setlocal enableExtensions disableDelayedExpansion set /a "n=100" for /r "%cd%" %%a in ("*.zip") do ( set /a "n+=1" set "file=%%~fa" set "filepath=%%~dpa" set "filename=%%~na" setlocal EnableDelayedExpansion set "rnd=!random!" md "!filepath!!n:~-2! - !rnd!" move "!...
by aGerman
24 May 2020 04:14
Forum: DOS Batch Forum
Topic: using sortable date as parameter without typing the date
Replies: 2
Views: 400

Re: using sortable date as parameter without typing the date

@echo off &setlocal for /f %%i in ('WMIC OS Get LocalDateTime /value') do for /f %%j in ("%%i") do set "%%j" set "d=%LocalDateTime:~,8%" :: echo %d% :: pause call "yourScript.bat" %d% There are two lines commented out, where you can check if %d% contains the today's date string. The last line shows...
by aGerman
24 May 2020 04:04
Forum: DOS Batch Forum
Topic: Just the total size of a folder & subfolders
Replies: 3
Views: 454

Re: Just the total size of a folder & subfolders

That's a piece of code I've once taken out from a thread here at DosTips. @echo off &setlocal set "folder=%userprofile%\Desktop" for /f "tokens=1,2 delims=: " %%a in ('robocopy "%folder%" "%folder%" /L /S /NJH /BYTES /FP /NC /NDL /NFL /TS /XJ /R:0 /W:0') do if /i "%%a"=="Bytes" set "size=%%b" echo %...
by aGerman
18 May 2020 08:48
Forum: DOS Batch Forum
Topic: [SOLVED] Extract rows with today's date.
Replies: 4
Views: 517

Re: Extract rows with today's date.

Did you run my example code and did it display the date in the format you need it? If so, just use it.

Steffen
by aGerman
18 May 2020 07:35
Forum: DOS Batch Forum
Topic: [SOLVED] Extract rows with today's date.
Replies: 4
Views: 517

Re: Extract rows with today's date.

… FindSTR "%date%" … If you run ... echo %date% ... and the format of the date doesn't match the format in your file then it can't be found. The format of the date variable is depending on local settings and not reliable. We already have lengthy threads about how to get date and time values in a un...
by aGerman
09 May 2020 17:58
Forum: DOS Batch Forum
Topic: Powershell comment
Replies: 7
Views: 1069

Re: Powershell comment

Indeed the creation of the necessary escaped line feed can be simplified. @echo off (set \n=^^^ %= This creates an escaped Line Feed - DO NOT ALTER =% ) PowerShell -Command ^& { %\n% # This is a comment %\n% Get-Service %\n% } pause You can read up in this thread https://www.dostips.com/forum/viewto...
by aGerman
08 May 2020 07:23
Forum: DOS Batch Forum
Topic: Powershell comment
Replies: 7
Views: 1069

Re: Powershell comment

The only other possibility that I can think of is to have the comment on the CMD side rather than on the PS side. Typically you would use a variable that expands to nothing in hybrid scripts like that.

Code: Select all

powershell -command "& {"^
%= this is a comment =%
Get-service^
"}"
Steffen
by aGerman
24 Apr 2020 15:17
Forum: DOS Batch Forum
Topic: Get IP from MAC adress?!
Replies: 6
Views: 1655

Re: Get IP from MAC adress?!

What do you get if you invoke an

Code: Select all

echo %1
in your code?

Steffen
by aGerman
17 Apr 2020 13:56
Forum: DOS Batch Forum
Topic: Searching a pattern in a website using curl in cmd
Replies: 12
Views: 2337

Re: Searching a pattern in a website using curl in cmd

Jeez :oops: Happens if you type code straight into the browser. Sorry.

Steffen
by aGerman
17 Apr 2020 06:34
Forum: DOS Batch Forum
Topic: Searching a pattern in a website using curl in cmd
Replies: 12
Views: 2337

Re: Searching a pattern in a website using curl in cmd

Would it maybe help to let curl save the data to a file and then search for the patterns? You could do this anyway, at least in order to evaluate if the lines that cause the error contain even data where you could find your patterns. So, if you're asking for the code - it's pretty straightforward: ...
by aGerman
16 Apr 2020 18:01
Forum: DOS Batch Forum
Topic: Searching a pattern in a website using curl in cmd
Replies: 12
Views: 2337

Re: Searching a pattern in a website using curl in cmd

Do you come from Germany? If yes, we could write in German I'm from Germany as well as penpen. However, this is an American forum and our users are from all over the world. Thus, English is the common language here and we're following this rule. However, the following notification appears: "FINDSTR...
by aGerman
16 Apr 2020 13:13
Forum: DOS Batch Forum
Topic: How to make a scanner that scans a batch file?
Replies: 3
Views: 1588

Re: How to make a scanner that scans a batch file?

Try to use FINDSTR. It supports multiple search patterns.

Steffen
by aGerman
16 Apr 2020 13:11
Forum: DOS Batch Forum
Topic: Run CMD as Network service account and execute commands without interaction
Replies: 2
Views: 1515

Re: Run CMD as Network service account and execute commands without interaction

Batch can't interact with the graphical user interface. It can't emulate key strokes and it can't emulate mouse input.
So, either the tool you call remotely has a command line interface that allows to pass all the necessary data as arguments when you call it, or you're likely out of luck.

Steffen
by aGerman
16 Apr 2020 13:05
Forum: DOS Batch Forum
Topic: Searching a pattern in a website using curl in cmd
Replies: 12
Views: 2337

Re: Searching a pattern in a website using curl in cmd

Probably something like that: curl "https://www.foobar.com/" | >nul findstr /c:"search me" && echo found || echo not found Note: curl outputs the HTML source text. If you have bad luck it doesn't contain the pattern you are looking for because content might get loaded by scripts dynamically. Steffen
by aGerman
14 Apr 2020 15:38
Forum: DOS Batch Forum
Topic: Sticky post (batch script collection)
Replies: 1
Views: 1513

Re: Sticky post (batch script collection)

Dave (in 2017) and I (in 2016) began to collect interesting and helpful topics over in the moderators corner of the forum. But alas - it seems we both failed to pursue for one reason or another :cry: Back then I already tried to gather some suggestions from you guys. With temperate participation tho...