Rename help

Hi all,

i need some help about rename feature.
i want to rename many files like this...

Before : directory opus - directory opus
After : DIRECTORY OPUS - Directory Opus

all caractere before "-" in upper case
all words after "-" with first letter upper case

:wink:

It's your lucky week! :smiley: I'm working on a Filename Format toolbar to post on the Centre here. You can be one of my testers.

This one was bit tricky. Opus Regular Expression has no provision for replacing an UPPER-cased or lower-case letter with its opposite-cased counterpart. However... Opus does provide upper or lower case file extensions. So we can leverage this to accomplish what you are looking for.

If this file:
subject title - chapter title.txt

Can become this file:
chapter title-txt -.subject title

we can make the new "file name" portion all Title case and the new "extension" all UPPER case like this
Chapter Title-txt -.SUBJECT TITLE

And then flip things back around to get:
SUBJECT TITLE - Chapter Title.txt

Which I believe is what you are after.

Files with more than one hyphen, will end up with only that last section of text in Title Case, like this:

BEFORE: watch - out for this - file name!.txt
AFTER: WATCH - OUT FOR THIS - File Name!.txt

This button can only be used on one selected file:[code]

<?xml version="1.0"?> {2450C4A3-AB93-4C9B-B089-9B3E6E929A70} UP - Title 1 Renames files in UP - Title format— "subject title - chapter title.txt" --> "SUBJECT TITLE - Chapter Title.txt" Only works for files with one spaced hyphen — full-auto, safe for only 1 file 16 RunMode Hide cmd.exe /c Echo.a {dlgstring|STOP! This button is only safe for 1 file at a time. This process beeps and displays a dialog, once all rename steps are completed. Do not click anywhere in Directory Opus until the completion dialog is displayed, as this might change the active lister! Don't try to use other applications during the rename, as the system focus constantly changes when each rename step is executed. Click CANCEL to abort safely. Click OK to proceed.| } sync: dopusrt /cmd Rename REGEXP PATTERN="(.*)\.(.*)#" TO="\1¬dot¬\2" sync: Ping -n 1 127.0.0.1 sync: dopusrt /cmd Select RESELECT sync: dopusrt /cmd Rename REGEXP PATTERN="(.*) - (.*)" TO="\2-.-\1" sync: Ping -n 1 127.0.0.1 sync: dopusrt /cmd Select RESELECT sync: dopusrt /cmd Rename FROM *.* TO *.* CASE=allwords sync: Ping -n 1 127.0.0.1 sync: dopusrt /cmd Select RESELECT sync: dopusrt /cmd Rename REGEXP PATTERN="(.*) (.*)#" TO="\1¬_¬\2" sync: Ping -n 1 127.0.0.1 sync: dopusrt /cmd Select RESELECT sync: dopusrt /cmd Rename CASE=extupper sync: Ping -n 1 127.0.0.1 sync: dopusrt /cmd Select RESELECT sync: dopusrt /cmd Rename REGEXP PATTERN="(.*)¬_¬(.*)#" TO="\1 \2" sync: Ping -n 1 127.0.0.1 sync: dopusrt /cmd Select RESELECT sync: dopusrt /cmd Rename REGEXP PATTERN="(.*)-.-(.*)" TO="\2 - \1" sync: Ping -n 1 127.0.0.1 sync: dopusrt /cmd Select RESELECT sync: dopusrt /cmd Rename REGEXP PATTERN="(.*)¬dot¬(.*)#" TO="\1.\2" sync: Ping -n 1 127.0.0.1 sync: dopusrt /cmd Select RESELECT sync: dopusrt /cmd Rename CASE=extlower sync: Ping -n 1 127.0.0.1 sync: dopusrt /cmd Set AUTOSIZECOLUMNS sync: Cmd.exe /c Echo.a sync: dopusrt /cmd {dlgstring|Format rename complete! :-)|" "} [/code]

There is a huge risk involved in using such a button on more than one file at a time. (Make yourself a test folder with 100 or so files and you will see what I mean.) When I post my toolbar (hopefully by the weekend) I will post a button version that can handle multiple selected files a little better.

To get that button to your toolbar, copy the code text, place Opus in Customize mode, right-click any toolbar and select paste. Test that out and see if it works for you.

Also, I should note, that this button is safe if you have already renamed a file to this format (Which I call UP - Title). A second pass will rename the file again; however, it just gets renamed back to UP - Title format with its file name intact.

waouuuuuuuuuuuuuuuuuu !!!!!!!!!
it's not very easy to rename one-by-one but...

many thanks

PS : Please add upper lower case option !!!!!!!!

I will have another button for you test shortly. I'm working on a whole file name format toolbar. It's tricky to get the the renames to work so there are no errors. (If you tried to use the button above on a folder with more than 10 or so files you will quickly see what what I'm talking about.)

I wanted to wait on the fast button to see if the slow one did what you wanted it to do.

I'm sorry, but I need more information. Do you mean this format?

SUBJECT TITLE - chapter title.txt

it's ok

but a little bug... when i select one file et click button, other file (no selected) change case...

It's an admin request. :wink:

If you want to do this in a way that's more reliable and fast (without all the ping-pauses) you could write a VBScript which Opus just passes a filename to that does the renaming. VBScript has access to a regular expressions object I think (or am I thinking of .Net... I think they both do though).

Thanks Leo,

But I think I'm going to stick with Opus RegExp and my scripting ability, now that I have over 40 hours of development and testing behind this toolbar.

I use the ping pauses to insure against a race state. The button posted above has them mainly because I'm being cautious. They are not strictly required when renaming one file, under most conditions. However, I have seen a number of these Format Renames get in a race state renaming only one file, when the PC's hard drive is thrashing pretty good. Lots of factors go into it, like: how long the file name is, how many files are involved, how many replacements are made in a single step, what else is accessing the hard drive, etc. I have one format rename button that takes over 13 steps to complete, many of them are recursive, using the "#" operator.

I actually do not code at all in VBScript (yet), even though I'm fluent in VBA. I have never even cracked open WSH. It's on my list though, someday in my free time.

I don't know, but I don't believe VBScript will help on my multi-file buttons. Could Opus pass 1000+ file names at once to a VBScript that chugs the new names and passes both the old new name back to Opus to rename all 1000+ at once? My scripted buttons work on 100s at a time right now. I've been testing them with 1281 test cases.

I make extensive use of the ping pause in the multi-file buttons. The user must calibrate the ping interval to their system performance though. I've already coded test cases, and a mostly automated calibration routine that is fairly novice-friendly. The user runs a test on their system and then edits the button to take out my warning dialog and put in a calibration factor. The button prompts the user for how many files are selected (I wish I could pick that up from the Opus Status Bar stats via an {argument}). Then the button scales the wait factor per 100 files and adds the calibration in.

I've already got a half dozen buttons encoded for different Format Renames.

Want to help me test them, before I release them into the wild?

The script just needs to be given the filename(s). There's probably a limit to how many you can pass at once so, for a very slight speed hit, you could run the script once per file and pass one name at a time. Doing it one file at a time also means you still get a nice Opus progress bar as the command does its stuff.

The script would work out the new name based on the old name and then rename the file. No need to pass anything back to Opus and no need to guess how long anything will take.

The only thing you can't easily handle with such a script is when the sets of old and new names overlap but that's not an issue in these examples.

Well it's something to consider in the future. but I'm going to stick with this for now. Get one version working to a point, then look at improving it.