home bbs files messages ]

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

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

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

   Message 42,416 of 42,547   
   Oliver to Zaidy036@air.isp.spam   
   Re: How do you remove ampersand from a W   
   17 Nov 24 17:30:05   
   
   XPost: alt.comp.os.windows-10, rec.photo.digital   
   From: ollie@invalid.net   
      
   On Sun, 17 Nov 2024 16:23:07 -0500, Zaidy036  wrote   
      
   >> When I figure out how to sed out the ampersand in a variable's definition   
   >> to replace with "and", I'll write back. Until then I'll use the previous   
   >> version which worked fine except when an ampersand was encountered.   
   >>   
   >> Thanks.   
   > Google finds:   
   > https://stackoverflow.com/questions/15995263/how-to-remove-spe   
   ial-characters-from-string-using-batch   
      
   Thanks. I can find lots of "similar" questions but all of them require a   
   *lot* of testing and changing since none are even close yet (although   
   almost any hit "sounds" close - it's not close when you test it out).'   
      
   But I do appreciate that you found that for me, which I duly inserted into   
   the code, which doesn't kill the code - but it also doesn't do the job.   
      
    @echo off   
    setlocal EnableDelayedExpansion   
    REM When I order the required 3 items a day, I enter them into this script.   
    REM Nothing is typed - everything is cut/pasted from an Amazon listing.   
    REM It creates the directories & template photo files for you.   
    REM That way the naming is consistent as you'll have thousands of these.   
    REM WIP It barfs on the ampersand as a pasted input (need to fix that).   
    REM An Amazon review title can be up to 100 characters only.   
    REM The ASIN is unique to each item you order on Amazon.   
    REM The BRAND should be mentioned in the review because you shill for them.   
    REM The ITEM is a colloquial name you use to describe the product.   
    REM The DESCRIPTION is an exact cut/paste of the Amazon item description.   
    REM The BULLETS are all the bullets on a single line (requires pre-processing)   
    REM The image file names are placeholders for eventual review images/videos.   
      
    REM The resulting date format is YYYYMMDD to keep sorts similar to Vine   
   output.   
    set today=%DATE:~10,4%%DATE:~7,2%%DATE:~4,2%   
      
    :BEGIN   
      
    REM Later you replace the 100 characters below with your review title.   
    set title=123456789 123456789 123456789 123456789 123456789 123456789   
   123456789 123456789 123456789 1234567890   
      
    set /p asin="ASIN: "   
      
    set /p brand="BRAND: "   
      
    set /p item="ITEM: "   
    set item=%item:.=,%   
    set output=   
    for %%a in (%item::=;%) do set output=!output!%%a-   
    rem Eliminate the last dash:   
    set output=%output:~0,-1%   
    echo Output: "%output%"   
    set item=%output%   
      
    set /p description="DESCRIPTION: "   
    set item=%item:.=,%   
    set output=   
    for %%a in (%description::=;%) do set output=!output!%%a-   
    rem Eliminate the last dash:   
    set output=%output:~0,-1%   
    echo Output: "%output%"   
    set description=%output%   
      
    set /p bullets="BULLETS: "   
    set bullets=%bullets:.=,%   
    set output=   
    for %%a in (%bullets::=;%) do set output=!output!%%a-   
    rem Eliminate the last dash:   
    set output=%output:~0,-1%   
    echo Output: "%output%"   
    set bullets=%output%   
      
    set dirname="%today% %brand% %item% %asin%"   
    set name="%brand% %item% %asin%"   
      
    mkdir %dirname%\%pic%   
    cd %dirname%   
      
    echo.%title% > %name%.txt   
    echo."%cd%\" >> %name%.txt   
    echo.ASIN=%asin% >> %name%.txt   
    echo.BRAND=%brand% >> %name%.txt   
    echo.ITEM=%item% >> %name%.txt   
    echo.DESCRIPTION=%description% >> %name%.txt   
    echo.BULLETS=%bullets% >> %name%.txt   
      
    REM cam/vid is for original camera images/photos (prior to processing).   
    REM pic is for images AFTER processing but not named consistently yet.   
    REM pic/jnk is for images/video AFTER processing & no longer needed.   
    REM pic/cap is for images/video AFTER processing & after adding captions.   
    REM You want cap so Irfanview batch commands have a place to put stuff.   
    REM wip is for any file that is useful to the review other than those above.   
      
    mkdir cam   
    mkdir cam\vid   
    mkdir pic   
    mkdir .\pic\jnk   
    mkdir .\pic\cap   
    mkdir wip   
    cd pic   
      
    REM This is an imagemagic command to create a dummy JPEG file.   
    convert -size 800x800 canvas: %name%_1a.jpg   
    convert -size 800x800 canvas: %name%_2a.jpg   
    convert -size 800x800 canvas: %name%_3a.jpg   
    convert -size 800x800 canvas: %name%_4a.jpg   
    convert -size 800x800 canvas: %name%_5a.jpg   
    convert -size 800x800 canvas: %name%_6a.jpg   
      
    cd ..\..   
      
    set /p repeat=Do you want to make another Amazon vine-review directory?[y/n]:   
    if %repeat%== y goto BEGIN   
    if not %repeat%== y goto END   
      
    END:   
    exit /B 0   
      
   I'll let folks know when/if I figure out how to get rid of the ampersand   
   when it's cut-and-pasted by the user into a variable via a query.   
      
   --- 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