Groups | Search | Server Info | Login | Register


Groups > alt.msdos.batch.nt > #19686

Re: Working batch script to append to the browser-independent global bookmarks file

From Marion <marion@facts.com>
Newsgroups alt.comp.os.windows-10, alt.msdos.batch, alt.msdos.batch.nt
Subject Re: Working batch script to append to the browser-independent global bookmarks file
Date 2025-01-24 01:13 +0000
Organization BWH Usenet Archive (https://usenet.blueworldhosting.com)
Message-ID <vmupes$k$1@nnrp.usenet.blueworldhosting.com> (permalink)
References <vmuih8$1go0$1@nnrp.usenet.blueworldhosting.com>

Cross-posted to 3 groups.

Show all headers | View raw


Here's another (more sophisticated) variant of the appending to a simple 
global bookmarks text HTML file, one per system, for all web browsers.

This batch file started with the prior batch file which simply added a 
defined bookmark given the exact URL and description... and flipped the 
algorithm around to simply ask for the desired search terms.

Assuming, for example, the desired search terms of "gas camp stove", 
this batch script below appends to a global search HTML text file.

While this approach can be applied to any search engine, my specific need 
was for the specific syntax of the Amazon and Amazon Vine search engines.
 <https://amazon.com> and <https://amazon.com/vine/about>

Note that the syntax for a purely Amazon search is the following:
<A HREF=https://amazon.com/s?k=gas+camp+stove>[amazon] gas camp stove</A><P> 

Note that the syntax for any specific Amazon Vine search is the following:
<A HREF=https://amazon.com/vine/vine-items?search=gas%20camp%20stove>[vine] gas camp stove</A><P> 

It was a pain getting the angle brackets escaped in the Windows batch
file but that was nothing in effort compared to the way Amazon does things
where there are plus signs ("+") and %20 characters in real search terms.

Specifically, it was most miserable getting the Vine %20 to be escaped.

Having figured it out today, the advantage of me kind-heartedly generously
posting my results for you to benefit from is that you can munge what I 
provide below to fit any search engine terms that you need to add for
your own global bookmarks search file (which everyone should have).

That makes all my effort writing this leveraged to everyone out there.
As always, please test & improve so that everyone benefits from every post.

   @echo off
   REM addvine.bat adds amazon & vine search links to a global Vine html file
   setlocal
   setlocal EnableDelayedExpansion
   
   REM #1 set your favorite text HTML editor
   REM set editor=notepad++
   set editor=gvim

   REM #2 set the location of your global vine search file
   set vinefile=C:\path\to\your\global\search\file\vine.htm
   echo.Global vine HTML search file is %vinefile%
   
   :input_item
   echo.Enter search item: ; for example, gas camp stove
   set /p "item="

   :replace_spaces_with_+
   set "amazon_item=%item: =+%" 

   :replace_spaces_with_%20
   set "vine_item="
   for %%a in (%item%) do (
     if "%%a"=="" (
       set "vine_item=!vine_item!%%20"
     ) else (
       if defined vine_item (
         set "vine_item=!vine_item!%%20" 
       )
       set "vine_item=!vine_item!%%a"
     )
   )

   echo Original item: %item%
   echo    Amazon item: %amazon_item%
   set vine_item=!vine_item!
   echo    Vine item: %vine_item%
   echo.Adding... "%amazon_item%" and "!vine_item!" to %vinefile%
   
   :append_html
   echo.^<A HREF=https://amazon.com/s?k=%amazon_item%^>[amazon] %item%^</A^>^<P^> >> %vinefile%
   echo.^<A HREF=https://amazon.com/vine/vine-items?search=%vine_item%^>[vine] %item%^</A^>^<P^> >> %vinefile%

   :edit_html
     echo Do you want to edit the global vine HTML file? [y/n] 
     set /p "choice="
     if /i "%choice%"=="y" ( 
       echo Editing file: %vinefile%
       %editor% %vinefile% 
     ) else if /i "%choice%"=="n" (
       echo File editing canceled.
   ) 
   
   pause
   endlocal
-- 

Back to alt.msdos.batch.nt | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Working batch script to append to the browser-independent global bookmarks file Marion <marion@facts.com> - 2025-01-23 23:14 +0000
  Re: Working batch script to append to the browser-independent global bookmarks file Marion <marion@facts.com> - 2025-01-24 01:13 +0000
  Re: Working batch script to append to the browser-independent global bookmarks file "R.Wieser" <address@is.invalid> - 2025-01-24 08:32 +0100

csiph-web