Rename a set of files based on regular expression [closed] - regex

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am looking to rename a large number of files that look like this on my ubuntu box:
MattTest Season 01 Episode 02 - Episode Name.mkv
Would like them to look like this:
MattTest S01E02 - Episode Name.mkv
Thanks

You could try the below rename command. \K keep up the previously matched characters from printing at the final. That is, character which are matched before \K are won't taken into consideration.
rename 's/^\S+\s+\K(.)\S*\s+(\S+)\s+(.)\S*\s+(\S+)/$1$2$3$4/' *.mkv
OR
rename 's/^\S+\s+\K(.)\S*\s+(\d+)\s+(.)\S*\s+(\d+)/$1$2$3$4/' *.mkv
Regex Demo

Related

Replace number with double quotes from csv file using vi editor [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I have a CSV file containing the data like below -
"Rank","Domain","Open Page Rank"
"1","fonts.googleapis.com","10.00"
"2","facebook.com","10.00"
"3","twitter.com","10.00"
"4","google.com","10.00"
"5","youtube.com","10.00"
"6","instagram.com","10.00"
"7","s.w.org","10.00"
"8","ajax.googleapis.com","10.00"
"9","linkedin.com","10.00"
How can I remove double quotes from all numbers here using vi editor or similar effect?
Thanks
you could use a regex search and replace:
%s/"\(\d\+\(\.\d\+\)\?\)"/\1/g
"on every line in the file, find...
all strings that start with a double quote...
followed by one or more digits...
optionally, followed by a period, which is followed by one or more digits...
followed by a double quote...
replace the string with the outer capture group...
and do it everywhere it appears on the line.
"

How to edit filenames in bulk using regex? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I don't even know if this is possible.
I have over 4 terabytes of MP3 files and I need a much faster way of editing files. I use a Mac running Yosemite if that makes any difference.
Here is a sample list of files
In bulk, how do I remove the "Elton John", space, hyphen, space, track number, and space from the names of these files, and only leave the track name and file format? Can it be done using terminal and if so, what's the command?
Thanks so much!
brew install rename
rename -v 's/\s*Elton John\s*-\s*\d+\s*-(.*)/$1/' *.mp3
You can use the -n option first to see what would be the changes without affecting the files name.

Custom wildcard configuration in postfix [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Is it possible to use wildcards in the postfix virtual file?
Instead of allowing #mydomain.com I would like to know whether I can permit a specific configuration of an email address, for example I would like all these to be accepted:
xyzabcTRE456#mydomain.com
xyzabcFRS869#mydomain.com
xyzdefGLY643#mydomain.com
Could I have a single line regex-type entry in the postfix virtual table to cope with these permutations?
Thanks
Tim
You can use configuration parameter check_recipient_access in your smtpd_*_restrictions.
e.g, your main.cf should contains
smtpd_recipient_restrictions = other rule, other rule,..., check_recipient_access regexp:/etc/postfix/access.me,...
Then /etc/postfix/access.me should contains your regex. This page and this page should help you.
/^xyzabc/ OK

Notepad++ regular expression [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
{\i that}
and,
{\i it is this}
I cannot find the way to delete extra stuff from expressions so as to keep only at the above example the words "that" and "it is this".
Can you help me with the regular expression needed?
Try each of the following two expressions (the first one is more efficient if the text between { and } can't contain a } symbol):
\{\\i ([^}]+)\}
Or,
\{\\i (.+?)\}
and in both cases replace with \1.
echo "{\i it is this}" | sed 's/{\\i //;s/}//'
Search : \{\\i (.+)\}
Replace with : \1

How can I trim a string starting with a specific expression? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
How do I find and delete the utm_content parameter from all the urls in a file using Notepad++?
Sample data:
http://example.com/content1.html?utm_content=product1
http://example.com/abc2.html?utm_content=homepage
http://example.com/test/?utm_content=sku1234
http://example.com/runapp?utm_content=31231KS
http://example.com/blabla?utm_content=nl-laptops-tablets
Desired result:
http://example.com/content1.html
http://example.com/abc2.html
http://example.com/test/
http://example.com/runapp
http://example.com/blabla
Note: As I understand Notepad++ regular expressions use the standard PCRE (Perl) syntax.
As far as I understand your needs:
search for:
\?utm_content=.*?"
and replace with "
Search for \?utm_content=\w+ or \?utm_content=.* and replace it with a zero string if this is the only one parameter.
Use standard Search & Replace (Ctrl + R)
Edit:
Search: utm_content
Replace:
Press find and then press Replace Rest.