home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 68,883 of 68,980   
   Marion to All   
   Re: Working batch script to append to th   
   24 Jan 25 01:13:01   
   
   XPost: alt.comp.os.windows-10, alt.msdos.batch   
   From: marion@facts.com   
      
   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.   
     and    
      
   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)   


[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca