21
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 03 Jun 2026
21 points (92.0% liked)
linux4noobs
3208 readers
3 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?
- Mention your Linux distro and relevant system details.
- Describe what you've tried so far.
- Share your solution even if you found it yourself.
- Do not delete your post. This allows other people to see possible solutions if they have a similar problem.
- Properly format any scripts, code, logs, or error messages.
- Be mindful to omit any sensitive information such as usernames, passwords, IP addresses, etc.
Community Rules
- Keep discussions respectful and amiable. This community is a space where individuals may freely inquire, exchange thoughts, express viewpoints, and extend help without encountering belittlement. We were all a noob at one point. Differing opinions and ideas is a normal part of discourse, but it must remain civil. Offenders will be warned and/or removed.
- Posts must be Linux oriented
- Spam or affiliate links will not be tolerated.
founded 2 years ago
MODERATORS
Tested this with perl-rename and it seems to work fine:
perl-rename -n 's/.* (\d{1,2}).* (\d{1,2})/sprintf "S%02dE%02d",$1,$2/e'*-n does a test-run and shows you the results, remove it to do the actual rename
's/ text to find / text to replace it with / modifier' is the format used
. represents any single character
'*' matches the previous character 1 or more times
'.* ' matches any series of characters before a space
() encloses something you want to keep
\ is the escape character
d represents any number
{1,2} means the number will be 1 or 2 digits
In the sprintf, %02d is to format each number with 2 digits.
$1 and $2 pass the first and second values enclosed in parentheses from the first argument into the 2 d's in the "S%02dE%02d" of the second argument.
This link has a better explanation of the /e modifier than I could give you xD
https://www.geeksforgeeks.org/perl/perl-e-modifier-in-regular-expression/ ___
Cool! Thanks!
Is this standard PERL stuff? How I learn what all these things mean? One day I hope to write my own arguments.
Perl has its own man pages, like commands do, but specifically for Perl stuff!
There's also a "perldoc" command that works a lot like man, that documents the functions and things.
For this, check out
perldoc -f s(thes"function") andman perlretut(regular expressions). MagnificentSteiner here is using/eon the end of the regex to write Perl code in the replacement instead of a string (that's mentioned in the perlre man page), and then using thesprintffunction to do some formatting, which,perldoc -f sprintf.For a general intro to Perl,
man perlintro!... Oh, uh, you may need to install the
perl-docpackage (or equivalent) to have any of this documentation.-- Frost
No idea lol
I just wanted a rename utility and Arch didn't have the GUI one I used on Mint so I gradually pieced some of this stuff together. If there's one source online that lays it all out I haven't found it yet!
If you'd like me to explain the one here I'll do my best ;)
Edit: nvm, I edited the original comment to explain everything