Drag N Drop rename

Hello

i'd like to rename a file with drag and drop.

ex :
i have a file movie.avi
and a subtitle file call subtitle.srt

i want to drag subtitle.srt and drop it on movie.avi to rename subitile.srt in movie.srt

i try with no luck to make a drag n drop raw command, but i failed
can someone help me

Thx

I can't think of a good way to do this. So if I wanted to accomplish the same goal, I'd just do a plain old fashioned drag and drop of the subitile.srt file. Next I'd copy the movie.avi filename without the .avi extension and then paste that name in place of subitile in the subitile.srt file.

If it would help, it should be fairly easy to create two hotkeys, one which copies the selected filename (minus the extension) to the clipboard and another which sets the selected file to the name in the clipboard (preserving the extension).

That would let you do something like a Ctrl-C / Ctrl-V (though with different hotkeys) to quickly copy the filename from one file to another.

If that sounds good shout and I'll reply with the commands.

yes , sounds good to me :smiley:

can you give me the two command please.

"Copy" command:

@firstfileonly @nofilenamequoting Clipboard SET {file$|noext}

"Paste" command:

Rename REGEXP PATTERN (.+)(\.[^.]+) TO "{clip}\2"

The first command puts the name of the first selected file, excluding its extension, into the clipboard.

The second command renames each selected file using what's in the clipboard, only preserving each file's extension.

Thanks for the great commands Leo :smiley:

I'm wondering if it's possible to adjust it so that when you paste the filename, it still keeps the inline rename open, with the cursor at the end of the pasted filename so that you can add something at the end of it. This would be useful to rename similar files in the same folder, because when you try to run the paste command and there's already a file with the same filename, you get an error. Any suggestions?

Try using this as the second command:

Rename REGEXP PATTERN (.+)(\.[^.]+) TO "{dlgstring|Enter base filename|{clip}}\2"

That's nice anyway as it lets you see what's in the clipboard and gives you a chance to cancel if it's not right.

Excellent! :smiley:

Works like a charm!

Thanks Leo,

Strange, the button Leo suggested above was working great but now, for some reason, it's stopped working for renaming folders. Or perhaps I just never noticed the quirk from the get-go.

Rename REGEXP PATTERN (.+)(\.[^.]+) TO "{dlgstring|Enter base filename|{clip}}\2"

It works perfectly for files, but not for folders. Looking at the regexp pattern has me a little confused...I think there's a portion of it that indicates a filename extension, but I'm not sure. Perhaps this is why it's not working on folders?

The button would only work on directories that had a . in their name.

The regular expression b(.[^.]+)[/b] looks for the last . in the name and then splits the name into what comes before it (the main file/folder name) and what comes after it (the file extension).

The \2 at the end of the command inserts that second thing (the file extension) at the end of the new name, so that the file extension is preserved.

If you just want to rename a folder (or a file, ignoring its extension completely) to what's in the clipboard you don't need to use regular expressions at all.

By looking at some other scripts and fiddling around with code, I seem to have something that works:

Rename PATTERN * TO "{dlgstring|Enter base filename|{clip}}.{ext}" FILEINFO AUTORENAME

The button works on both files and directories. However, I'm not sure if there's a simpler way of going about it. I haven't tested it out enough to see if it will work in all scenarios.

[quote="mamecab"]Hello

i'd like to rename a file with drag and drop.

ex :
i have a file movie.avi
and a subtitle file call subtitle.srt

i want to drag subtitle.srt and drop it on movie.avi to rename subitile.srt in movie.srt

i try with no luck to make a drag n drop raw command, but i failed
can someone help me

Thx[/quote]

With New drag and drop ability of Opus 10 is it possible to do that ?

No, dropping a file on to another file isn't possible, except if the target file is an EXE (which would run the EXE with the file you dragged as an argument).

It might be possible via some kind of shell extension, but not by any simple config change that I know of. Using the clipboard still seems like the best bet.

Or you could make a rename script or some other command that is passed the names of both files and works out which rename to do.

thanks for this quick answer
and by the way : V10 is :smiley: