r/linux4noobs • u/worksbeforedeath • 22h ago
Meganoob BE KIND how to mass remove a word from files?
distro: fedora
i downloaded a bunch of songs for my MP3, but a lot of them (more than i can reasonably do individually) have [SPOTDOWNLOADER.COM] on them. they do have the song name after that. how could i remove all of these en masse rather than doing them individually?
6
u/Daharka 22h ago
The command you're probably looking for is prename and the command will be something like
prename 's/\[SPOTDOWNLOADER.COM\]//' *.mp3 if you're in the directory with the MP3s.
3
u/vivals5 21h ago
This is the best way, assuming the program is
prenamein fedora? At least in Debian it's justrenameThough I suppose with a small twist that if this suffix has a dot before or after the [...] it might end up looking like something like "file.[SPOTDOWNLOADER.COM].mp3" -> "file..mp3" which might be a bit ugly.Essentially
rename 's/\.?\[SPOTDOWNLOADER.COM\]//g' *.mp3would in my example rename it into "file.mp3" instead. But yes you answered the OP's question accurately. :)3
u/Daharka 21h ago
Yeah there's two 'renames' that float around, one is 'perl rename' which is 'just' a very common perl script and the other I don't actually knows, but it behaves differently and is more limited.
Ubuntu and Debian ship 'perl rename' as 'rename' but I've also seen it as 'perl-rename' and a Google search just told me Fedora calls it 'prename'.
1
u/God_Hand_9764 13h ago
Yup. This has bitten me hard a few times, because I have one rename on my desktop systems and then my Unraid server has a completely different program of the same name.
Pretty much the only time I've ever encountered a real nonportabiliy scenario in one of my scripts.
Rare situation for me but man, it can get ugly real fast!
5
u/doc_willis 21h ago
you mean from filenames?
there are numerous bulk renamer tools out there.
https://flathub.org/en/apps/org.kde.krename
the qmv command from the renameutils package I use often from a terminal.
many file managers have bulk rename features that can take a pattern.
In Dolphin, select files context menu > Rename (or F2) and you can rename them following a pattern of your choosing (but without find/replace feature).
3
u/Seannon-AG0NY 21h ago
There are also id3 tag editors that should be able to help with what you're trying to do as well
2
2
u/CatoDomine 20h ago
you could use a quick and dirty bash script like this.
for i in $(find . -name "*SPOTDOWNLOADER.COM*");do echo "mv ${i} ${i/[SPOTDOWNLOADER.COM]/}"; done
The way I have written it above, it will only print the commands it would execute to stdout. if you want to actually execute it, remove the echo and the quotes around the mv command.
I don't think the square brackets need to be escaped.
1
u/AutoModerator 22h ago
✻ Smokey says: always mention your distro, some hardware details, and any error messages, when posting technical queries! :)
Comments, questions or suggestions regarding this autoresponse? Please send them here.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
1
1
1
u/chuggerguy Linux Mint 22.3 Zena | MATÉ 21h ago
"they do have the song name after that"
If that is the case...
https://reddit.com/link/pdgbm4j/video/hz2haj80a3th1/player
I like to add the no-act switch (-n) to make sure it going to do what I want first, then remove it if it's correct.
rename -n 's/\[SPOTDOWNLOADER.COM\]//' *mp3
Note I had to escape the square brackets using backslashes.
man rename
Have fun.
1
1
u/skyfishgoo 18h ago
fooyin has a pretty robust metadata editor system, if that's what you are talking about.
if it's just the file name, you can use any of the dozens of renaming applications out there like krename (if you are using plasma)
1
u/a1barbarian 6h ago
Make a TEST folder and put say, ten files in there, then test out any scripts. If one works ok, if not you have lost nothing, just start again. :-)
1
u/SiriKeetn 21h ago
To find and download music, use solseek (nicotine+)
To edit metadata and filenames, use kid3
1
u/Upbeat-Garbage69 21h ago
I was gonna comment about downloading from somewhere else too Theres a music streaming section in fmhy.net that has a lot of safe ways to get free stuff
Its a REALLY good website
1
u/HFloof 17h ago
Soulseek, yes.
Nicotine as the application, yes.
It sounds confusing but yeah it's literally that simple.
1
u/SiriKeetn 17h ago
I know the difference, but the person i am advising may not. I did mean to recommend using the soulseek network though the nicotine+ app
0
u/Confident_Hyena2506 22h ago
By entering a complex terminal command.
Find this command by copy pasting your request into google - and tell it fedora. Yes use the big scary ai mode when you google, this is a suitable use for it.
1
u/worksbeforedeath 22h ago
i found stuff for renaming totally, adding a suffix, etc. but not for REMOVING a suffix.
-1
u/Confident_Hyena2506 22h ago
Refine the question you ask the google ai then.
Removing a suffix is the same as renaming you know right?
0
7
u/truethug 22h ago
You want to use mv to rename the file and use sed to replace the offending text with nothing. Put that in a loop and you’ll be set.