You are not logged in.
Sorry if my question belonngs elsewhere.
I'm looking for a way to rename subtitles files with different names to match their counterpart media file, for example:
tv.show.e01.srt from tv.show.e01.aviAll media files have the same name, for example:
tv.show.e01.avi
tv.show.e02.avi
tv.show.e03.avi
...But the downloaded subtitles have different names and thunar batch file renamer doesn't have such feature as I want it.
Any ideas?
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.
* AUR contributor.
Offline
What are the "different" names? And what is the logic of how those different names should be matched to the appropriate media file?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
What are the "different" names? And what is the logic of how those different names should be matched to the appropriate media file?
I have subtitles names like:
tvshow.e01.by-TM.srt
tv-show.e02.Galaxy.srt
tvshow.e03.someuser.srtand all media files have this same spec format name:
tv.show.e01.avi
tv.show.e02.avi
tv.show.e03.avi
...* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.
* AUR contributor.
Offline
And ...
And what is the logic of how those different names should be matched to the appropriate media file?
If it is just the number, and the numbers are unique, then the following would do:
#!/bin/sh
for f in *.srt; do
mv $f tv.show.e$(echo $f | tr -cd '[0-9]').srt
doneBut assuming you've not precisely described the goal, you should have backups before you make any attempts.
Last edited by Trilby (2023-05-14 04:01:13)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I don't know which DE you use, but Thunar has a bulk rename plugin which does just that.
https://docs.xfce.org/xfce/thunar/bulk-renamer/start
Last edited by SimonJ (2023-05-14 04:59:01)
Rlu: 222126
Offline
Another option is to use edir to bring all the files up within your favorite editor and hand edit and/or globally replace characters to make all the file names consistent. I use vim so using column selection, repeat commands, macros, undo etc I find I can rename many inconsistent files very quickly. Once you can see all the files are named as you want then the changes are not actioned until you quit your editor so it is hard to make a mistake. edir is available in the AUR.
Offline
emacs has such a feature built in (wdired-change-to-wdired-mode).
Offline
emacs has such a feature built in
Offline
I don't know which DE you use, but Thunar has a bulk rename plugin which does just that.
Yes, I know, but I don't know how to match my intended task, for example:
Before:
tvshow.e01.by-TM.srt
tv-show.e02.Galaxy.srt
tvshow.e03.someuser.srtAfter:
tv.show.e01.srt
tv.show.e03.srt
tv.show.e03.srt* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.
* AUR contributor.
Offline
What's wrong w/ Tilby's script?
If this is bash and you're concerned about digits showing up in other places and ".e[0-9]*." is a solid pattern you can (safely) preview the renaming w/
for name in *.srt; do [[ $name =~ \.e[0-9]*\. ]]; echo "$name => tv.show${BASH_REMATCH}srt"; doneOffline
It depends on how many files you have, and how repeatable are the name patterns; but you're probably looking for a regexp + manual cleanup of stragglers.
For both of those things I'll suggest qmv from the renameutils package. Call it like that:
qmv -f do *.srtThis will open you editor with the list of .srt files in current directory.
You can then change the filenames to desired ones, either manually or using your editor's search and replace functionality.
Once you're done, just save and close the editor, and qmv will rename all the files to what you entered.
As for the patterns: I assume "tv.show" in your examples is just a placeholder, and the files have actual show names there, just with different punctuation.
In such case, you should be able to select all filenames for a specific show, and use a regexp replace from something like
.*(e[0-9]+).*\.srtto
<name>.\1.srtwhere '<name>' is the desired show name.
Offline
What's wrong w/ Tilby's script?
If this is bash and you're concerned about digits showing up in other places and ".e[0-9]*." is a solid pattern you can (safely) preview the renaming w/
for name in *.srt; do [[ $name =~ \.e[0-9]*\. ]]; echo "$name => tv.show${BASH_REMATCH}srt"; done
OK. I'll try it.
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.
* AUR contributor.
Offline