Multi rename: Convert only parts of name to uppercase

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
ScoopyDoo
Junior Member
Junior Member
Posts: 3
Joined: 2012-06-27, 01:13 UTC

Multi rename: Convert only parts of name to uppercase

Post by *ScoopyDoo »

Convert only parts of the filnames to uppercase

Here's my question. What about when only parts of the filnames need to be converted to uppercase?

ie. I want everything between '' '' converted to uppercase

filename1 ''comment''
filname200 ''comment''
anotherfilname ''tag''


Looking forward thanks!
User avatar
white
Power Member
Power Member
Posts: 6015
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

[mod]Split from Multi rename, remove last characters

White (moderator)
[/mod]
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

I somehow doubt that you've got double quotes in your filenames. Please use examples that are as close to your real filenames as possible.
User avatar
nsp
Power Member
Power Member
Posts: 1954
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

ScoopyDoo wrote:Here's my question. What about when only parts of the filnames need to be converted to uppercase?

ie. I want everything between '' '' converted to uppercase

filename1 ''comment''
filname200 ''comment''
anotherfilname ''tag''

Looking forward thanks!
There is no built-in function in the replace part that can allows you to modify such nor uppercase in replaced part....
If you need very dedicated stuff, can program some scripting and do not care of 64bit support. You can use "script content plugin" and use it in MRT with a user defined script.

If you do not care of doing it inside TC, you can use MRS http://code.google.com/p/multi-rename-script/
User avatar
white
Power Member
Power Member
Posts: 6015
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ScoopyDoo wrote:What about when only parts of the filnames need to be converted to uppercase?

ie. I want everything between '' '' converted to uppercase

filename1 ''comment''
filname200 ''comment''
anotherfilname ''tag''
Using tc only without the use of any plugins, I see several possibilities. But it requires two rename operations. I don't think it can be done in one go.

It further depends on the naming scheme. How can the comments and tags be differentiated from the file name? Are they separated by the first space in the file name?
ScoopyDoo
Junior Member
Junior Member
Posts: 3
Joined: 2012-06-27, 01:13 UTC

Post by *ScoopyDoo »

I use 2* ' to make double quotes.

And yes the space in front of the first '' is the same in all filenames to be changed.

The text between ''?'' is of variable length so I really need a way to search for everything between double quotes within the filnames (which I have, search for: ''(.*?)'' replace with: $1 ) but somehow change $1 to uppercase.
User avatar
white
Power Member
Power Member
Posts: 6015
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

My suggestion is:
Step 1: Move the text between quotes to a location where it can be changed to uppercase.
Step 2: Change the text to uppercase and move it back.

For example:

Add quoted text as extension at the end of the file name:

Code: Select all

Search for     : (''.*'').*$
Replace with   : $&.$1

Checked options: [E] and RegEx
Change extension to uppercase and move back:

Code: Select all

Extension mask : [U][E]

Search for     : ''.*''(.*)\.(''.*'')$
Replace with   : $2$1

Checked options: [E] and RegEx
jvh
Member
Member
Posts: 187
Joined: 2007-07-20, 12:28 UTC

Post by *jvh »

Probably can be done in one step, please try this setting:

Code: Select all

Rename mask: file name: [n][N]-----[U][N]
Extension             : [n][E]

Search for            : ^([^']+)'.*-----[^']+(.*)
Replace with          : $1$2
RegEx                 : YES
User avatar
white
Power Member
Power Member
Posts: 6015
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

2jvh

Good one!

This one leaves file names intact when there is no text between quotes and handles optional text after the quoted text:

Code: Select all

Rename mask: file name: [N]\[U][N][n]

Search for            : (.*?)''.*''(.*)\\.*?(''.*'').*|\\.*
Replace with          : $1$3$2
RegEx                 : YES
[E]                   : NO
ScoopyDoo
Junior Member
Junior Member
Posts: 3
Joined: 2012-06-27, 01:13 UTC

Post by *ScoopyDoo »

Can someone please do a breakdown of what JVH' code does. I understand the first and last part. But what about the sub-expression part (the middle)?

^([^']+)'.*-----[^']+(.*) < I don' t understand

Thank you all btw it did the trick. But now I want to uinderstand it as well.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

It is a regular expression, you may read about them in TC help or in Internet.
Expression "^([^']+)'.*-----[^']+(.*)" finds all until first "'" character and marks as $1 (first subexpression) and then it finds all starting with "'" after "-----" and marks as $2 (second subexpression) so you can use theese subexpressions in replace pattern.

E.g.:
Original name: filname200 ''comment''
Name after renaming: filname200 ''comment''-----FILNAME200 ''COMMENT''
Regular expression finds: filname200 ''comment''-----FILNAME200 ''COMMENT''
Replacing gets: filname200 ''COMMENT''
Post Reply