XPost: alt.comp.os.windows-10, alt.comp.software.firefox   
   From: marion@facts.com   
      
   For everyone to benefit who cares about creating a search HTML bookmark that   
   will create clickable links to any desired search engines, below is my latest   
   attempt at appending to a dual global Amazon/Vine search bookmarks file.   
      
   Note that the syntax for a purely Amazon search is the following:   
   [amazon] gas camp stove   
      
   Note that the syntax for any specific Amazon Vine search is the following:   
   [vine]   
   gas camp stove    
      
   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.^[amazon]    
   item%^^ >> %vinefile%   
    echo.^[vine]   
   %item%^^ >> %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   
   --   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|