I have a collection of files with names like these:

Ace of Aces (Europe).mp4
Action Fighter (USA, Europe) (v1.2).mp4
Addams Family, The (Europe).mp4
Aerial Assault (USA).mp4
After Burner (World).mp4
Air Rescue (Europe).mp4
Aladdin (Europe).mp4
Alex Kidd - High-Tech World (USA, Europe).mp4
Alex Kidd in Miracle World (USA, Europe) (v1.1).mp4
Alex Kidd in Shinobi World (USA, Europe).mp4
Alex Kidd - The Lost Stars (World).mp4
Alf (USA).mp4
Alien 3 (Europe).mp4
Alien Storm (Europe).mp4
Alien Syndrome (USA, Europe).mp4
Altered Beast (USA, Europe).mp4
American Baseball (Europe).mp4
American Pro Football (Europe).mp4
Andre Agassi Tennis (Europe).mp4
Arcade Smash Hits (Europe).mp4
Assault City (Europe) (Light Phaser).mp4

(I have these filenames listed in a text file.) 

I have to get away from parentheses, so I would like to rename the files to remove the parentheses and the text between them, so the filenames will be as follows:

Ace of Aces.mp4
Action Fighter.mp4
Addams Family, The.mp4
Aerial Assaul.mp4
After Burner.mp4
Air Rescue.mp4
Alex Kidd - High-Tech World.mp4
Alex Kidd in Miracle World.mp4
Alex Kidd in Shinobi World.mp4
Alex Kidd - The Lost Stars.mp4
Alien 3.mp4
Alien Storm.mp4
Alien Syndrome.mp4
Altered Beast.mp4
American Baseball.mp4
American Pro Footbal.mp4
Andre Agassi Tennis.mp4
Arcade Smash Hits.mp4
Assault City.mp4

Ideally, any solution should alert me if I have, for example, files like Aladdin (Europe).mp4 and Aladdin (Asia).mp4,  or Ghostbusters (1984).mp4 and Ghostbusters (2016).mp4, and not destroy any files.

  • Are you on a gnu/linux system with the "rename" or "prename" utility?
    – Jeff Schaller
    Sep 4, 2018 at 13:00
  • 2
    Also, are you renaming files, or editing a text file?
    – Jeff Schaller
    Sep 4, 2018 at 13:00
  • I only need rename files, and yes there is rename.
    – tommy
    Sep 4, 2018 at 13:00
  • 1
    What happens if you have Aladdin (Europe).mp4 and Aladdin (Asia).mp4, for example?
    – Jeff Schaller
    Sep 4, 2018 at 13:03
  • 1
    it could be a problem because i have to get away all things from parenthesis
    – tommy
    Sep 4, 2018 at 13:04

2 Answers 2


Using Perl's rename commandline:

Use this :

rename 's/\s*\([^\)]+\)//g' *.mp4

Remove -n (aka dry-run) when the output looks satisfactory.


With zsh, (also checks for conflicts):

autoload zmv # best in ~/.zshrc
zmv -n '*' '${f//[[:space:]]#[(]*[)]}'

Remove -n or replace with -v when happy.

With //, we remove all occurrences of (...), but since the * is greedy, there will only be at most one match anyway. On 1 (2) 3 (4), it would match " (2) 3 (4)". You can make the * non-greedy by using the S parameter expansion flag:

zmv -n '*' '${(S)f//[[:space:]]#[(]*[)]}'

Or replace * with [^)]# (0 or more non-)s).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.