I am using Ubuntu 20.04.2
with GNU sed version 4.7
. I have a bunch of music files that got named weirdly because they did not have all the info I specified to be in the file name. For example, "Bruno Mars - NA - Bruno Mars - The Lazy Song.aiff" Basically, the NA is put in place of the year because that is unknown. What I want to do is rename all of these files to omit the "- NA -" and everything before that, so the file comes out to be "Bruno Mars - The Lazy Song.aiff"
Here is my problem and what I have tried so far:
I coppied a few of the affected files to a different folder and used the command sed 's/^.*NA -//' *
to try and fix the naming, but I started to get very weird output from the terminal, see this. I have tried reinstalling sed, using rename sed 's/^.*NA -//' *
and perl -pi -e 's/^.*NA -//' *
and none of them have worked; however, the rename and perl commands have not produced the same, weird output as before. My gut is telling me that my regex is incorrect, but the documentation says that this should work. Any help is appreciated. Thanks!
sed 's/^.*NA -//' *
would not rename files, it would attempt to replace the pattern in the files' contents, streaming the result to the terminal (with potentially weird results, especially if the expansion of*
includes any binary files). – steeldriver May 04 '21 at 19:34rename
command, not sed: see https://manpages.ubuntu.com/manpages/focal/en/man1/prename.1p.html – glenn jackman May 04 '21 at 19:58Error, this is a private paste or is pending moderation. If this paste belongs to you, please login to Pastebin to view it.
– mchid May 04 '21 at 20:11mmv '* - NA - *.aiff' '#2.aiff'
– May 05 '21 at 06:18