Results 1 to 3 of 3

Thread: Remove dashes from filenames

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

    Remove dashes from filenames

    This removes spaces in filenames.

    How can I also remove dashes - ?

    Code:
    rename "s/ //g" *
    Ubuntu Mate 18.04 Bionic
    Mate Desktop

  2. #2
    Join Date
    May 2010
    Beans
    1,697

    Re: Remove dashes from filenames

    Make a test file with touch and you can play

    Possibly
    Code:
    touch ~/dashtest.txt
    rename "s/\-//g" ~/dashtest.txt
    I'm not at my system so can't test personally but it's a dummy file (a test) so no harm is done. If it's OK then move to prime time (be sure your data is backed up too just in case)

  3. #3
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Remove dashes from filenames

    The rename command used by Ubuntu is based on perl, so check out: https://perldoc.perl.org/perlre.html

    Code:
    rename -n 's/[ -]//g' ./*.txt
    should do the trick.

    The -n or -nono flag means No action. Check out the man page for details.

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
  •