Search code examples
macosfile-renamerenaming

How to remove a reoccuring word/character and what comes after, from the filenames of multiple files?


I have several folders of video files where, due to the download manager I use, they are all named in the following format "FILENAME.mp4; filename= FILENAME.mp4" All I've been trying to do is to remove everything after (and including) ".mp4; filename". However, I haven't found a way to do this.

I have tried some free software (such as Renamer, Namechanger, Name Munger for Mac, Transnomino) but I failed to do what I need to.

I'm working on Mac OSX 10.13.6.

Any help with this issue would be appreciated.


Solution

  • You can achieve it using Terminal. Go to the folder where you want to rename files using this cd command, for example:

    cd ~/Documents/Videos
    

    And run this command to rename all files recursively:

    find . -iname "*.mp4;*" | sed -E 's/(\.[^\.]*)(\.mp4)(.*)/mv "\1\2\3" "\1\2"/' | sh
    

    This command will keep only FILENAME.mp4 part from FILENAME.mp4; filename= FILENAME.mp4 file name