7 thoughts on “Remove File Extension using sed

  1. Worked great for me. Thanks for posting this. Just for info, I used it help convert a bunch of pictures with the following one liner:-
    for f in *.JPG;do g=`echo f|sed ‘s/\..\{3\}//’`;convert -resize 800×600 f thumbs/g.eps ;done

  2. This is nice b/c unlike a lot of solutions, if there exists a ‘.’ somewhere in the filename, e.g. “ILikeToSeparateDates_w-periods(2011.02.20).mp4” it does not remove the date.

  3. Samuel, try this:

    $ echo “ILikeToSeparateDates_w-periods(2011.02.20).mp4” | sed ‘s/\(.*\)…./\1/’

  4. I’d use something like:

    FULL=`echo 1`
    {FULL} | sed ‘s:.*\.::’`::g
    CLIP=`echo {FULL} | sed -e{EDIT}`
    echo ${FULL}

    This works fine on
    and even on
    “IncludedExtensionInName(good mp4 of 2011.02.20).mp4”
    but slightly mangles
    RecussiveName(badName.mp4 of 2011.02.20).mp4
    RecussiveName(badName of 2011.02.20)

Leave a Reply

Your email address will not be published. Required fields are marked *