Hello,
I am using krename to rename files from something like aaa_bbbb to aaa bbb, that is, to replace the underscore with a space. This works ok if I enter the space manually in the interface.
However, I have saved the renaming scheme (which is more complex, as it contains other manipulations). When I load the saved scheme and try to apply it, the substitution does not work: the underscore is deleted, but it is not replaced with a space. Also, the space is not present in its interface field after loading the renaming scheme. It is as if upon loading the renaming scheme, the space is ignored.
My question is if there is a way to make the space be inserted correctly after reloading the scheme, other than manually inputting it in the interface.
I’m assuming that only having the space in the Replace With: field without any other text surrounding it (or anything else generally) is what’s causing the problem. I have perhaps an odd solution, which I’ve tested, that uses a regular expression, which you could test yourself to see if it works for you.
Create a Find and Replace... item
Tick Find is a Regular Expression
Tick Process tokens in replace string
In the Find: field, enter (.?)_+(.?)
In the Replace With: field, enter \1 \2 (with a space between the tokens)
Confirm if this works and save the settings that include this item in it.
I don’t know how familiar you are with regular expressions, but to provide some explanation just in case you aren’t familiar or other people are interested, for the regex:
The (.?) matches zero or one occurrence of any character, so whether or not there’s a single character before or after the underscore, it should match.
Additionally having the parentheses () around the match captures whatever matches.
The _+ matches one or more occurrences of the underscore character.
The combined Find: regex is looking for zero or one instance of any character, before and after one or more underscore characters. It’s also capturing the zero or one instance of any character, both before and after.
In the Replace With: field, the captured matches can be output in the replaced text and are the tokens represented with a slash followed by the capture number in order, so \1 is the token matching the first capture (before the underscore) and \2 is the token matching the second capture (after the underscore).
Using a variant of your example let’s say you have aaZ_Abbbb, it’s matching the Z_A portion, capturing the Z and the A matches, then replacing Z_A with the Z, a space, then the A so the matching portion becomes Z A and the replaced text should be aaZ Abbbb.
I’m pretty sure this should do what you need and since the space in the Replace With: is surrounded by other text (which is where I think part of the issue lies), it ensure that you can save the the Find and Replace... settings.
Hi, I just came across this post, looking for an answer to the krename regex. I have a problem where a file has spaces and the dreaded question mark and parentheses. Your solution for the replacement work well for spaces. I have tried some iterations that do not seem to work for the ? or ( or ) using ? or ( or ) .
Original File Name:
The_Unseen_Eye - But why 13?-(1288p).mp4
(.?)?+(.?)
(.?)?+(.?)
(.?)‘?’+(.?)
(.?)'?'+(.?)
(.?)“?”+(.?)
OR
(.?))+(.?)
(.?)(+(.?)
If you’re trying to match on a question mark using Regular Expressions you’d need to put a slash before the question mark which would show as \?, for the regex to match that.
Having said that, a look at the filename you’ve provided, that question mark is apparently a “Fullwidth Question Mark” and not a regular one, so you should be able to use (.?)?(.?), which should match the instance of the question mark and then you could replace that with a space.
If you do also want to replace a parentheses, you could actually put a slash before it like \( or if you were wanting to replace all parentheses you could put them in square brackets to create a character set like [()].
Hi, Thanks! This does work now - I had no idea this “?” was not a regular one! Copied the actual char from the filename, then inserted into the regex and it worked. Also, the [()] worked a treat, thanks again! I saved the regex from the options provided as krename,xml this is it -for anyone looking for info in future.
I am trying to rearrange several filenames of varying lengths with Krename. I need the last 10 digits(for example 2018-06-09) moved to the middle of the filename. I cant figure out how to select the last 10 digits from multiple filenames.
For example, I have some files:
The Regular Show Xtra Regular 2018-06-09.mp4 and
The Regular Show This title is much longer 2019-05-03.mp4
I would like to put the date after the title of the show but before the title of the episode. So:
The Regular Show 2018-06-09 Xtra Regular.mp4
The Regular Show 2019-05-03 This title is much longer.mp4
Anyone know how to do this? I have a few hundred files….
It’s been a while since I’ve been on here and just noticed your query.
If the dates are always formatted the same way as a sequence of 4-2-2 digits and it always starts with “The Regular Show”, then the following **should **do what you’re after, but you’ll want to check when you go to rename.
Find: (The Regular Show )(.+)( )(\d{4}-\d{2}-\d{2})*$
Replace With: \1\4\3\2
This assumes the checkboxes for regular expression and processing tokens are both ticked of course.