Search found 3740 matches

by aGerman
10 Jul 2020 05:52
Forum: DOS Batch Forum
Topic: Code logic problem - transform lines to columns
Replies: 4
Views: 113

Re: Code logic problem - transform lines to columns

May I ask why you DisableDelayedExpansion for the variable setting at the beginning? That's just to be safe in case your real file names contain exclamation points. Can't tell why the code doesn't work for you. I wasn't facing any problems for the snippet you provided. There are numerous possible r...
by aGerman
08 Jul 2020 11:30
Forum: DOS Batch Forum
Topic: Code logic problem - transform lines to columns
Replies: 4
Views: 113

Re: Code logic problem - transform lines to columns

This may work for you. @echo off &setlocal DisableDelayedExpansion set "infile=foo.txt" set "outfile=bar.txt" set "tab= " set "firsttoken=" setlocal EnableDelayedExpansion <"!infile!" >"!outfile!" ( for /f %%i in ('type "!infile!"^|find /c /v ""') do for /l %%j in (1 1 %%i) do ( if not defined first...
by aGerman
02 Jul 2020 12:54
Forum: DOS Batch Forum
Topic: CSV to .URL shortcut
Replies: 1
Views: 112

Re: CSV to .URL shortcut

Yes in general this is possible. Links with .url file exension are simple text files. However, could you please be more precise in regards of how the csv lines look like. Especially whether or not the comma has surrounding spaces as in your current example. Steffen // EDIT: Okay actually it doesn't ...
by aGerman
24 May 2020 04:39
Forum: DOS Batch Forum
Topic: Create random folders and move files in them
Replies: 3
Views: 579

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

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

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

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

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

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

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

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

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

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

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

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

Try to use FINDSTR. It supports multiple search patterns.

Steffen