I have many files like these
0678 - Puzzle Series Vol. 5 - Slither Link (J).nds
0679 - Puzzle Series Vol. 6 - Illust Logic (J).nds
0680 - Puzzle Series Vol. 7 - Crossword 2 (J).nds
and would like remove the leading four digit numbers and the dash, so they become
Puzzle Series Vol. 5 - Slither Link (J).nds
Puzzle Series Vol. 6 - Illust Logic (J).nds
Puzzle Series Vol. 7 - Crossword 2 (J).nds
When I try with prename
I get
$ prename -i 's/???? - (.+nds)/$1/' *nds
Quantifier follows nothing in regex; marked by <-- HERE in m/? <-- HERE ??? - (.+nds)/ at (eval 1) line 1.
Question
Can someone see what I am doing wrong?
?
doesn't mean what you think it means. It means the previous atom is optional. For example /^ab?\\z/
matches a
and ab
.
Use .
to match any character except a line feed. /s
makes .
any character, period.
s/.... - (.+nds)/$1/
s/.{4} - (.+nds)/$1/ # Readability improvement.
s/.{4} - (.+nds)/$1/s # No need to prevent `.` from matching a LF.
s/^.{4} - (.+nds)/$1/s # Better to anchor for readability if nothing else.
s/^\d{4} - (.+nds)/$1/s # A bit more restrictive, and more self-documenting.
s/^\d+ - (.+nds)/$1/s # Do we really need to check that there are exactly 4?
s/^\d+ - (.*)/$1/s # No point in checking if `nds` is contained.
s/^\d+ - //
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.