Results 1 to 10 of 11

Thread: Test if a file extension is supplied for script

Threaded View

  1. #1
    Join Date
    Aug 2016
    Location
    El Lago, Texas
    Beans
    674
    Distro
    Ubuntu Mate

    Test if a file extension is supplied for script

    How can I test if .jpg file extension is supplied?

    Code:
    #!/bin/bash
    # 
    #----------------------------------------------------------------------------
    # Convert a jpg file(that is a scan of text like a book page) to a text file
    #  Image MUST be a jpg file !!
    #
    #----------------------------------------------------------------------------
    
    #!/bin/bash
    clear
    [ -z "$1" ] && {
    echo 
    echo -e "Error!! NO JPG SPECIFIED. !!"
    echo
    echo -e "Convert jpg to text file."
    echo 
    echo -e "Image2File.sh [name of jpg file WITHOUT file extension.]"
    echo
    exit 1; }
    convert "$1.jpg" "$1.tiff" &&
    tesseract "$1.tiff" "$1"
    rm *.tiff
    Last edited by raleigh3; August 7th, 2020 at 06:14 PM.
    Ubuntu Mate 18.04 Bionic
    Mate Desktop

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •