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,406 of 42,547   
   Oliver to All   
   How do you remove ampersand from a Win10   
   15 Nov 24 22:42:02   
   
   XPost: alt.comp.os.windows-10, rec.photo.digital   
   From: ollie@invalid.net   
      
   How do you remove the ampersand from the batch file user input?   
      
   Nothing is typed for the input to this batch script I hacked out.   
   Everything is copied & pasted from the Amazon listing for the item.   
    Working Example:    
    ASIN: B09X12TBC2   
    BRAND: Microsoft   
    ITEM: Windows installer   
    DESCRIPTION: Windows 11 Home 64bit Retail USB   
    BULLETS: Brand Microsoft Model Name KW9-00633 Screen Size 13.3 Inches   
   Operating System Windows 11 Home Special Feature Lightweight Graphics Card   
   Description Integrated Graphics Coprocessor ARM Mali-T604 Resolution 1080p   
   Connectivity Technology USB    
   Processor Count 1   
      
   But if a special character such as an ampersand is present, it fails.   
   Otherwise, it works.   
      
   Everything is pulled off the Amazon description which sometimes has   
   special characters which Windows barfs on in that Amazon description.   
      
   Below is the script I hacked out to create consistent Amazon directories of   
   stuff I've ordered (as Vine requires you to order at least 80 items) & then   
   I use those folders to write consistent reviews (to remain in the program).   
      
   The batch output fails if there is an ampersand (or special character) in   
   the input. But the batch file works if no ampersand is copied & pasted.   
      
   If I could figure out how to convert an inputted cut-&-paste that contains   
   an ampersand to an "and" then I could likely figure out how to do it for   
   the rest of the special characters that make MSDOS fail in batch input.   
      
   Therefore my question asked of you is how to swap an ampersand to an "and"?   
      
   I can't yet get these suggestions to work on the INPUT with an ampersand.   
   https://stackoverflow.com/questions/14107975/escape-ampersands-i   
   -variables-win-batch   
      
   Instead of using the Microsoft real world example, these test inputs work.   
    ASIN: myasin   
    BRAND: mybrand   
    ITEM: my item   
    DESCRIPTION: my description   
    BULLETS: my bullet1 my bullet2   
      
   But any test input containing an ampersand fails (with random results).   
    ASIN: myasin   
    BRAND: my brand   
    ITEM: my & item   
    DESCRIPTION: my & description   
    BULLETS: my bullet1 & my bullet2   
      
   How can I convert the ampersand to the word "and" in the batch output?   
      
      =====< cut for the createVineFolders.bat file >======   
    @echo off   
    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 Amazon.   
    REM The BRAND should be mentioned in the review because you work 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%   
      
    @echo off   
    :BEGIN   
      
    REM Obviously 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 /p description="DESCRIPTION: "   
    set /p bullets="BULLETS: "   
      
    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 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 dummy JPEG files.   
    REM The point is to save edited results to consistent file names.   
    REM This eliminates complex typing which begets mistakes.   
    REM Plus it's easier to save over a file than to create the file name.   
    convert -size 800x800 canvas: %name%_1a.jpg   
    convert -size 800x800 canvas: %name%_2a.jpg   
    convert -size 800x800 canvas: %name%_3a.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   
      =====< cut for the createVineFolders.bat file >======   
      
   --- 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