I have a huge number of files and folders and they are all formatted differently i.e. FILENAME-FILE or Filename.File or FileNAME.FiLE. Instead of using the renaming feature from the toolbar I would prefer to use the context menu. Is it possible to rename files and folders in lowercase and replace ./-+= with either underscores or spaces?
It is, but why not use the rename button? You can do them all in one go if you e.g. drag everything you need to rename into a temporary file collection. (If they're all in one place already then you don't even need to do that.)
Hi Leo, I've had a good look through advanced renaming options and can't see an option to replace .-+= symbols with spaces or underscores? Perhaps you can show me how this feature works?
Using a script in a context menu for a specific task looks like a quicker way of processing multiple separate files, or do you know a quicker way using the renaming button.
Thanks again for your support
Here's one example of how it could be done. You could save it as a preset for quick access, or turn it into a command to put on a button or context menu if you wish:
^(.*)(\.|-|\+|=)(.*\..+)$#
\1 \3
Hi Leo, I followed your example and couldn't get it to work. I can convert the text to 'all lower case' using the standard rename option but that's about it.
If I select 'Regular Expressions' only the first file in the list is highlighted, all the other files are greyed out. When I click OK only the first file is converted to lower text, the rest remain unchanged.
I've had a look through preferences and can't see anything obvious that would preventing me getting the same result, how odd
Difficult to guess. Maybe showing us a screenshot of your rename dialog will make it obvious what was missed.
I have just realised why they are greyed out, some of the text has different symbols and spaces and they just need adding to the script you posted.
How do I add the [space] [#] [~] symbols to the script?
Can you point me to a good resource to learn more about dopus scripts, it would help if I knew what programming language this is ~ dohh!
Thanks again Leo
There's no script here, just regular expressions. The manual covers the basics and there are more examples in the Rename Presets area. There are also lots of tutorials on the web about regular expressions, although watch out because almost everything uses a slightly different version of them, just to confuse things.
Let's look at the old name string:
^(.*)(\.|-|\+|=)(.*\..+)$#
This part in the middle is the important bit:
(\.|-|\+|=)
That says: find a .
-
+
or =
The .
and +
have a \
before them, because they have special meanings normally and you need the \.
to say "I want an actual .
character" and \+
to say "I want an actual +
character".
So if you want to add space, #
and ~
then you might end up with this:
(\.|-|\+|=| |#|~)
Putting it back with the other bits:
^(.*)(\.|-|\+|=| |#|~)(.*\..+)$#
Note: I haven't tested this, so apologies if I got something slightly wrong. It's possible the #
or ~
need a \
before them like the .
and +
did, but not as far as I am aware.
That's working fine Leo, great work.
Now that I've added them as presets is there any way they can be added to the drop-down menu on the rename button or will I need to add my own button to the toolbar?
Cheers
Instead of the slower alternation:
(\.|-|\+|=| |#|~)
use a character class:
[-~.+=\s#]
Make a button which runs a command like this: Rename PRESET="Your Preset Name" and that should do the job.
You can add the same thing to a context menu (or hotkey, etc.) if you still want that, too.
MrC's character class method is better, too. I wanted to use that myself but found something wasn't working when I tried, and I didn't have a chance to work out what I was doing wrong so I used the other (not quite as good) method.
A quick guess would be that the dash was not the first or last character, and so acted as a Range operator in a character range.
How would the full string appear? Out of curiosity I thought I would try your version but couldn't get it to work, the text is just greyed out.
Any ideas?
Old name: ^(.*)[-~.+=#\s](.*\..+)$#
New name: \1_\2
Note: you can't have a space or \s
character inside the character class and use it to break apart the words in New name. If you want to use a space to separate words in New name, remove the \s
in the character class:
Old name: ^(.*)[-~.+=#](.*\..+)$#