I'm trying to rename a bunch of files, using the rename command, from
Blue - This file is called Blue ok.txt
Red - This file is called Red ok.txt
Orange and Yellow - This file is called Orange and Yellow ok.txt
... into:
Blue.txt
Red.txt
Orange and Yellow.txt
I'm having trouble getting it to understand the wildcard in the middle. I've tried:
rename -f 's/ - This file is called* ok//gi' *.txt
d* ok
in your regex means zero-or-mored
characters followed by " ok". You wantd.* ok
, which meansd
followed by zero-or-more of any character, followed by " ok". – cas Apr 26 '21 at 03:44