22
submitted 3 days ago* (last edited 3 days ago) by schipelblorp@sh.itjust.works to c/linux4noobs@programming.dev

Hi, y'all. Running Linux Mint and I have the puzzle presented above.

From what I gather, I'm using rename (1p) which makes mention of Perl and in the man page it says it will also run as file-rename. I'm not sure if this is the right rename utility for the common argument

s/old_pattern/new_pattern/

but any time I try to run anything (including -n), I just get an angle bracket > and have to ctrl-c out.

I'd also need some details on how the wildcards work, which seems to be lacking in the documentation.

Edit: Instructions unclear. I have a bunch of episodes that are very wordy. I'm moving them onto DVD and truncated on my player the directory will look like:

Star Trek The Next Gene....
Star Trek The Next Gene....
Star Trek The Next Gene....
Star Trek The Next Gene....
Star Trek The Next Gene....

so I want to take (sample episode)

Star Trek The Next Generation Season 1 Episode 1 - Encounter at Far Point

and

  • Replace 'Star Trek The Next Generation Season ' with 'S0'

  • Replace 'Episode ' with 'E0' or 'E' depending on digits

  • Keep episode title as is.

So it looks like

S01E01 - Encounter at Farpoint.mkv

you are viewing a single comment's thread
view the rest of the comments
[-] SanderZeldenthuis@nord.pub 2 points 3 days ago
mv “Star Trek Next Generation Season 1 Episode 1 - Encounter at Farpoint.mkv” “S01E01 - Encounter at Far Point.mkv”  

Or am I missing something about what you're trying to do?

[-] teft@piefed.social 2 points 3 days ago

I think he wants to rename more than one file. Sounds like he wants to rename entire folders using that formula.

[-] schipelblorp@sh.itjust.works 1 points 3 days ago

Yes, the “etc.” part. Imagine I have 7*24 episodes following this convention. How do I rename them all in one swell foop?

find command with an exec. Basically, find can list files matching a pattern and then run a command for each of them. The exec will probably be a bit gnarly, though, so if you want something a little more palatable, you want a script that grabs the names of the files into a variable, then takes each entry via a for loop (find command and a bash while read might work), stores it in a variable, changes it based on your pattern (sed might work here), stores the changed name in another variable and then mv $former-name $new-name

[-] SanderZeldenthuis@nord.pub 1 points 3 days ago* (last edited 3 days ago)

If the naming of each series is that consistent, you could just use parameters in bash and build the new title out of it and then do the rename, in a loop. It would be a very short shell script.

eta: using printf to format the new title variable will let it handle the number formatting clearnly, like 01 for 1

eta: something like this

for f in *"Season "*; do s_ep="${f#*Season }"; s="${s_ep%% Episode*}"; ep_t="${s_ep#*Episode }"; ep="${ep_t%% - *}"; t="${ep_t#* - }"; printf -v new "S%02dE%02d - %s" "$s" "$ep" "$t"; mv "$f" "$new"; done 
this post was submitted on 03 Jun 2026
22 points (100.0% liked)

linux4noobs

4190 readers
2 users here now

linux4noobs


Noob Friendly, Expert Enabling

Whether you're a seasoned pro or the noobiest of noobs, you've found the right place for Linux support and information. With a dedication to supporting free and open source software, this community aims to ensure Linux fits your needs and works for you. From troubleshooting to tutorials, practical tips, news and more, all aspects of Linux are warmly welcomed. Join a community of like-minded enthusiasts and professionals driving Linux's ongoing evolution.


Seeking Support?

Community Rules

founded 2 years ago
MODERATORS