Search found 33 matches

by Shohreh
14 Sep 2023 08:00
Forum: DOS Batch Forum
Topic: [SOLVED] grep + HTML angle brackets?
Replies: 3
Views: 5293

Re: grep + HTML angle brackets?

Thanks for the infos.

Turns out the "Binaries" file also requires the "Dependencies", which I missed.

https://gnuwin32.sourceforge.net/packages/grep.htm

It's working OK.
by Shohreh
13 Sep 2023 06:29
Forum: DOS Batch Forum
Topic: [SOLVED] grep + HTML angle brackets?
Replies: 3
Views: 5293

[SOLVED] grep + HTML angle brackets?

Hello, Unless there's a better alternative, I tried GNU grep 2.5.4 but it fails finding lines with HTML tags. Is there a way in Windows10's cmd to accept angle brackets? C:\>grep --version C:\>grep --help C:\>grep C:\>grep -Poha "<h2>" input.html C:\>grep -Poha "^<h2^>" input.html Thank you.
by Shohreh
27 May 2023 00:43
Forum: DOS Batch Forum
Topic: Rename filename to remove invalid characters?
Replies: 0
Views: 24151

Rename filename to remove invalid characters?

Hello, I'd like to use an HTML's title as filename, but it may contain invalid characters like question marks, etc. Do you know of a way to rewrite a string so that it's DOS-legit? FOR /F "delims=" %%A IN ('xidel "%1" -se "title:=//title" --output-format cmd') DO %%A echo %title% wget -O "%title%.ht...
by Shohreh
15 May 2023 02:48
Forum: DOS Batch Forum
Topic: Edit file in loop?
Replies: 0
Views: 24277

Edit file in loop?

Hello, I'd like to add a "Last updated YYYY-MM-DD" line at the bottom of all HTML files in a directory, right before </body>. Is there a way to modifiy each file in the loop, instead of eg. saving the edit into a temporary file, and replacing the original with the temp file? @echo off set dt=%DATE:~...
by Shohreh
24 Sep 2022 13:13
Forum: DOS Batch Forum
Topic: [SOLVED] Read grep's output and send email?
Replies: 4
Views: 2760

Re: Read grep's output and send email?

Thanks for the tip on ERRORLEVEL . @echo off echo Looking for Something wget -qO - https://www.acme.com | grep -c "Something" IF %ERRORLEVEL% NEQ 0 (echo Not found) ELSE (echo Found) I found a simpler way to send an e-mail: mailsend.exe -t me@acme.com -f me@acme.com -smtp smtp.isp.com -sub "Test mes...
by Shohreh
24 Sep 2022 11:35
Forum: DOS Batch Forum
Topic: [SOLVED] Read grep's output and send email?
Replies: 4
Views: 2760

Re: Read grep's output and send email?

Thanks, although curl's output is full of HTML while grep only returns 0/1.

Code: Select all

@echo off
echo Check something
wget -qO - https://www.acme.com | grep -c "something"
The next step is to 1) check the result, and if it's 1, send an email (eg. mail.exe -s "Found" -to me@isp.com smtp.isp.com).
by Shohreh
24 Sep 2022 10:38
Forum: DOS Batch Forum
Topic: [SOLVED] Read grep's output and send email?
Replies: 4
Views: 2760

[SOLVED] Read grep's output and send email?

Hello, I need to check for a pattern in a web page, and send an e-mail depending on the output from grep which can be either 0/1 depending on if the pattern is found. Does someone know of 1. a way to do this in CMD 2. a single EXE email app to send e-mail through my ISP's SMTP server? wget -qO - htt...
by Shohreh
11 Oct 2021 03:35
Forum: DOS Batch Forum
Topic: Batch files only opens some files
Replies: 2
Views: 4238

Batch files only opens some files

Hello, I'm using the following list of commands to launch an application and open documents in the same instance, ie. the application is only launched once: REM open.docs.cmd start " " "C:\Program Files\SumatraPDF\SumatraPDF.exe" -reuse-instance "C:\Doc1.pdf" start " " "C:\Program Files\SumatraPDF\S...
by Shohreh
25 Aug 2020 07:55
Forum: DOS Batch Forum
Topic: Loop and append different string to each file?
Replies: 2
Views: 3202

Re: Loop and append different string to each file?

Simple enough :-) Still, would it be possible to use a second loop, since I won't know the names of the input files? I only used 1.txt 2.txt as examples. @echo off if "%~1"=="" GOTO PARAM setlocal enableextensions enabledelayedexpansion set items[0]="Some text" set items[1]="Some other text" set ite...
by Shohreh
25 Aug 2020 05:47
Forum: DOS Batch Forum
Topic: Loop and append different string to each file?
Replies: 2
Views: 3202

Loop and append different string to each file?

Hello, I'd like your input on how to solve this problem. I need to write a loop to 1) read all TXT files in a directory, and 2) insert a different string in each file. Pseudo-code: for %%f in (*.TXT) DO ( ECHO Handling %%f SELECT CASE CASE 1.TXT: echo "some text" >> %%f CASE 2.TXT: echo "some other ...
by Shohreh
11 Aug 2020 05:27
Forum: DOS Batch Forum
Topic: [SOLVED] How to get filename from URL and set it to variable?
Replies: 3
Views: 4626

[SOLVED] How to get filename from URL and set it to variable?

Hello, In a batch file, I need to rip the filename from a URL, and set it to variable. This doesn't work ("| was unexpected at this time."): REM Usage: mybatch.bat http://www.acme.com/myfile.html → extract "myfile.html" REM OK echo %1 | sed "s/.*\///" for /f %%i in ('echo %1 | sed "s/.*\///"') do se...
by Shohreh
07 Jun 2020 04:38
Forum: DOS Batch Forum
Topic: Redirect output to file without using > sign?
Replies: 12
Views: 9625

Re: Redirect output to file without using > sign?

The problem is that an input file may contain tens of thousands of track points, ie. latitude + longtidude tuples.

Maybe I should just forget about cmd batch files for this task, and require installing a full scripting language like Perl or Python.
by Shohreh
07 Jun 2020 04:12
Forum: DOS Batch Forum
Topic: Redirect output to file without using > sign?
Replies: 12
Views: 9625

Re: Redirect output to file without using > sign?

Can method #2 be modified somehow to include a call to grep in the middle, so that I can fetch track points from GPX files, insert them, and then append the end of the structure? @Echo OFF (For /F "Skip=2 Tokens=2 Delims=<>" %%A in (%~F0) Do Echo/^<%%A^>)>Output.xml Goto :EOF :<?xml version="1.0" en...