Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Mass rename of files replacing '_' with space

    How do you mass rename files from the command line? I have a bunch of mp3's with filenames like:

    I want to convert all the "_"(underscore) to " "(space). I tried:
    $ for i in *; do mv "$i" `echo $i | tr '_' ' '`; done

    but it complains that:
    mv: target `name.mp3' is not a directory.

    What am i doing wrong?

  2. #2
    Just Joined! richiefrich's Avatar
    Join Date
    May 2006
    I got's two you can try
    for i in ./*.mp3; do mv echo "$i" "${i//_/ }"; done
    if the output looks ok, remove the echo

    pipe this --> sed -e 's/ /_/'

    kinda like this
    find /mp3 -iname '*.mp3' -exec echo "$i" "`echo $i | sed -e 's/_/ /'" \;

  3. #3

    $ for i in *_*; do mv "$i" "`echo $i | tr '_' ' '`"; done

  4. $spacer_open

Posting Permissions

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