Renaming - Multi File Renaming Questions

Hello Everyone,

Question #1
In Directory Opus when you go to rename a single file using F2 it enters the inline renamer for that single file in the lister.
It also allows you to highlight multiple files in the lister and then hit F2 and based on the last file that was selected (one that has a rectangle around it) it will enter the same inline renamer allowing you to change the name of that last selected file while all the other files are still highlighted. Upon hitting enter that single file is the only one that gets renamed.

Does anyone know if there is a way to script a numbering sequence to the end of the file and have all the others follow suit?
I would like to be able to type in a new file name and upon hitting enter have it add _(1) to the file name and rename the other files accordingly, all done right there in the lister.

Example: Before
apple.txt
balloon.jpg
car.pdf (this file has the rectangle around it)

Then you window highlight "apple" down to "car" and hit F2
You rename "car.pdf" to "Car Guide" and upon hitting enter you get the following
Example: After
Car Guide (2).txt
Car Guide (3).jpg
Car Guide (1).pdf

Does anyone have an idea if this can be done?
Thank You

Yes you could do that in a script. Have a dialogue ask for the base name then then in the script rename each file appending the _(n).
You would want craft the new file name and check if it already exists before doing the rename. If it already exists increment n by 1 and try again.
Have a crack at it, if you get stuck I (or someone else) can give you a hand.
Generally you are asked to link you account if asking for someone to write a script for you. If you have purchased Dopus please link you account.

Thanks for the response but as I mentioned I am new to Directory Opus so this is unfortunately over my head.
To be honest I am still trying to figure out how to use the built in multi file renamer correctly, so I am thinking writing my own script would probably be a disaster.
If I understand what you mentioned above "If it already exists increment n by 1 and try again" that was going to be my next question, how to add to the script the ability to add to an already existing sequence that already contains a _(#).
Example: Before
apple.txt
balloon.jpg
Car Guide (1).pdf (this file has the rectangle around it)
Car Guide (2).txt

Highlighting the above files and hitting F2 would enter the inline renamer to the "Car Guide (1).pdf" file and when you hit enter it would recognize the _(1) and piggyback off of the file number renaming the other files accordingly.

Example: After
Car Guide (3).txt
Car Guide (4).jpg
Car Guide (1).pdf (this file has the rectangle around it)
Car Guide (2).txt

If that is what you meant by that. Anyways thank you again for your response and to all of those who took the time to read my post.

I have not had a lot of exp with the rename, there are a couple of people around that are really good with it. If someone knows the answer I'm sure they will post.

If you have purchased Dopus, "Please link your account to your registration." and I will look at creating a script to do what you want.

Cheers

Thank you again for the response, as I mentioned I am new to Directory Opus, therefore I am in testing mode, therefore I am currently using the Demo Version.
I was trying not to draw a ton of attention to that fact, because I am having a hard enough time getting someone interested enough in creating such a script.
Luckily someone keeps on bringing it up.

I am currently trying to test out as much as I can with the program until my demo expires.
I have a huge list of questions so I am just trying to get as many questions answered as I can.
My next option is installing the Demo to my Desktop computer when my trial runs out so that I can hopefully be able to test out a renamer script as well as the answers to all my other questions, if I get answers to them.

Due to the fact that many people found Directory Opus because they were looking for an alternative to the File Explorer found in Windows 7, I would have thought that more people would have been interested in this request, because they used this feature in Windows XP and they miss it, and if they didn't use it maybe see how valuable it would be to have. If a script like this was created I would imagine it would benefit others because then it could be tweaked to suit other peoples renaming styles as well, depending on how others number sequence their files.

Am I the only one on this site that views a multi file inline renamer is a valid desire, there are no "registered" users that would find this helpful to back me up?
I used this feature in Windows XP File Explorer a great deal and I was just hoping it would have been available in Directory Opus. I thought it was a clever idea someone came up with when developing the Windows XP file explorer.

Like I said I don't have the knowledge to be able to script something like this myself, I have never programmed anything before.
To be able to scripts things like how this script would go by the last file selected instead of sort order top to bottom, and having it recognize if other numbers in the sequence already exist sounds like it would be a little too complicated for me to attempt at this time.

After testing so many file explorers one of my main goals in choosing Directory Opus was so that I could stop having to go to forums and ask people to program/script things for me, but yet here I am again. I figured with DO having the ability to allow scripts to be used that I would have found some scripters who were hungry. Again I babble, sorry everyone.

Anyways thanks again for the response, I appreciate you taking the time to read me requests.

[quote="miketurn1234"]
Like I said I don't have the knowledge to be able to script something like this myself, I have never programmed anything before.
To be able to scripts things like how this script would go by the last file selected instead of sort order top to bottom, and having it recognize if other numbers in the sequence already exist sounds like it would be a little too complicated for me to attempt at this time.[/quote]

Most of us started off in the same position. Unless you are going to expect someone here to deal with a renaming issue every time you have one – I don't think that is part of the support package – you are going to have to dive in and teach yourself some of the rudiments. Then, when you get stuck, you are in a better position to ask meaningful questions and to understand the answers.

As to your question, wowbagger suggested "you could do that in a script".

You replied "this is unfortunately over my head".

Am I interpreting this correctly in that scripting goes over your head?

(Me too, incidentally.)

If so, then the Help file is a good place to start. Then there are the example scripts with the program and those on the appropriate forum section.

My own first resort when trying to do renaming things is to highlight the files I want to change and then to use the Rename function and play around with the various options. Regular expressions are hairy but extremely useful. When I have worked out how to do something, I then go about creating a way to repeat the process in future.

If you look at the Standard Rename option, you will see in the Help file that it offers Numbering Files.

Forgive me if you have tried all this already, but your responses, especially the last one, seem to be more "philosophical" than technical, so it is hard to tell.

I don't think the click-order is preserved when passing arguments to rename scripts. See:

User commands, templates, flags, and argument order

This is to get you started and maybe even more interested in this scripting-thing sooner or later, who knows? o)

I've attached a jscript file, remove the txt-extension and drag it over to the preferences->toolbars->scripts section - a new user defined command will be available in DO after that.
It's called "RenameBaseNameContinueNumbering", sorry - nothing better came up my mind.. o)

The code section below shows a button, which makes use of the new rename command, copy this code into your clipboard and paste that onto any toolbar while in customize mode.
A new button is going to appear, making use of that command added before. Combining this with "F2" is not covered, so you need to make use of this new button for now or create a another hotkey for this e.g..

This thing won't fit your expectations to 100% I think, but you should be able to see what's possible with DO and maybe even use it seriously for those two scenarios you described.
If no file has been found which carries a number, a dialog will appear allowing to set a new basename for all selected files (default is the basename of the first file of your selection).
If a numbered file or files were detected, the basename of the first one of those will be used as basename for those not yet numbered. Files which are already numbered, won't be affected at all.
Currently files will be named like those in your examples -> "my filename (x).ext", though the rename will catch up numbers from anywhere in a filename, be aware of that please.

Be careful, use this on test files only, until it seems to work stable for you (and if not, well.. o). I'll take no responsibility on your data of course. o)

<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>RenameBaseNameContinueNumbering</label> <icon1>#newcommand</icon1> <function type="normal"> <instruction>RenameBaseNameContinueNumbering</instruction> </function> </button>
RenameBaseNameContinueNumbering.js.txt (3.88 KB)

Hey Guys

Sorry it took me a little while to respond, I really just haven’t been feeling to good lately. Anyways thank you for the responses, but the biggest THANK YOU goes to Tbone for taking the time to provide an actual script to get things started.
This is an extremely kind and generous act, also thank you for providing detailed directions of how to apply the script and for creating the button as well.

I did a great deal of thorough testing of the script, as Tbone mentioned it might not work 100% but I found it to be a great start (extremely impressive). Hopefully others will maybe be able to add some things to this script, to help to get it to as close to 100% as possible, now that Tbone has laid the foundation.

I will be creating separate replies to this thread for each tweak if anyone else feels as generous as Tbone and they want to take a crack at the modifications.

I am still in amazement that someone was not only kind enough to write me a script but it actually works.

Thanks Again
I really hope others will be able to make use of this script as well.

Due to the fact that I babble on, I am going to try to skip explaining my reasoning for the tweaks. If anyone has any questions please let me know.

TWEAK #1 Weird Error
When you use this tool to rename files, if you make a mistake renaming and try to undo the process, you get an error that states the following…
An error occurred moving “filename”
Source and destination must be different to move files

In doing a little more research, when you look into the “Undo List” within DO it displays the files renamed with this script as a “Move” as opposed to a “Rename” so when try to undo the action that is why the above error appears.
Not sure why it would consider the action to be a “move” but is there a way to fix this so that undo's can be applied?

TWEAK #2
Within this script new renaming takes place in a popup box field, is there a way to make the renaming be done directly from the lister itself within the F2 Inline Renamer?

#T1
I think a rename on filesystem level is identical to a move, or a move is identical to a rename.
You can for example rename "C:\test.txt" to c:\myfolder\test.txt" and the file would be moved to that folder (while keeping it's name in that case).
This is true at least as long as you're a on the same device/volume. If you move a file from volume A to B, it is always a copy and when that's done a delete on the original. Why DO claims it cannot "undo" I cannot say exactly, maybe Leo or Jon can say something to that. What the script command does is calling "RENAME FROM .. TO .." only (and that's on the same volume).

#T2
I think currently it is not possible to get rid of the popup-box. I don't know of a way to recognize inline renames by script add-ins, which would be the first thing needed I guess. Having something triggered in DO whenever a rename (inline in this case) happened, would be quite useful for other things as well I guess, but right now, there's now way. It may be possible to use F2 as usual though and in case there are multiple files selected, automatically switch to that popup-box thing and do your basename-renames. I would need to play some more with that to make sure that' works.

Thanks for your feedback! o)

#T2
If the "do it all by F2-keypress" thing works out, the popup-box may serve as a nice indicator to you, that you're a not in the regular inline-rename mode, which affects a single file only - instead you're about to rename multiple files. So it has some kind of usage I guess if you're willing to accept it at all. o)

Hey TBone great to hear back from you, thanks again for all of your help and also in general for sticking with me.

TWEAK #1
Yeah not sure, like I said if I do a rename of a file with the Inline Renamer or the Advanced Renamer within DO and I go into the "Edit" pulldown menu and select the "Undo List" it shows in the cascade menu that the actions are considered to be "Rename", but if I use the Renamer Script the actions are said to be "Move".
I think when you undo DO is trying to move the file back to where it came from, but because they are in the same place and were never moved to begin with, you get the error that the source and the destination are the same.

TWEAK #2
First off just to clarify, although I would preffer the script to be able to work within the lister, the popup box is a minor issue, just the fact that you were able to get this to work at all is amazing. I was just not sure if this was possible, when going through the manual under the "Inline Renamer" section I noticed the creators of DO added extra features to it but I was not sure if that was script based or a deeper level of coding.
The next part you mentioned about is as if you read my mind because that was going to be one of my next questions, I will label that a different tweak number in the following reply.

TWEAK #3
Would it be possible when you hit F2 for the script to be able to recognize whether a single file is selected or multiple files are selected.
F2 when Single File Selected = Inline Renamer
F2 when Multiple Files Selected = Script is activated, popup box appears

If the above cannot be accomplished, if possible, another option to this that may be nice would be to edit the script so that if a single file is selected then have it NOT add the _(1) to the end of the file. This way you can set the F2 hotkey to the script button and the popup box would handle both single file renames as well as multi file renames.

TWEAK #4
Is there a specific line in the script that can allow you to set the Width of the popup box?
(Probably not, but even cooler) Or a way to make the popup box be able to be stretched horizontally to any desired size and have it remember that width?

TWEAK #5
Is there a way to set the renamer popup box to have the filename highlighted automatically when opened, this way you can start to type immediately, replacing the entire existing filename?

Just checking in to see if anyone else would be willing to participate in continuing work on this script?

Thanks again

[quote="miketurn1234"]Just checking in to see if anyone else would be willing to participate in continuing work on this script?

Thanks again[/quote]
I'd like Tweak #3.

Seems so obvious to me that I'm surprised it isn't the default. But my "programming" skills don't stretch that far.

T#1
I tested and it turns out, the rename is considered a move, if you add the path (which does not change in this case) to the new name, so this is fixable easily.

T#3
Yes, I consider this possible.

T#4 + T#5
Right now not possible with DO itself, afaik.
One could use a 3rd party tool/library which is more flexible to show that popup though.

Now what about you buy that awesomeness of filemanager and I will do #1+#3 for you? o)

[quote="tbone"]T#1
rename is considered a move[/quote]

Always worth remembering that you can use rename to move files in Opus.

I use it all the time. It is especially useful when picking up metadata from mp3 files and moving them to new locations based on that metadata.

This is explained in the Help file section Renaming with Metadata. But you sure have to dig it out.

The nomenclature sort of makes sense, if you work on the basis that the "rename" covers not just the filename. But it would not surprise me if this puzzles some users.