GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Rename a file to its parent folder's name

Hi,

I have file in a folder that I would like to be able to rename to the file's parent folder name. So for example, I have a file C:\TV\ProgramNameS01E07\BlahBlah.mkv and I'd like to rename the file BlahBlah.mkv to ProgramNameS01E07. It would be great to do this via the right-click menu or a button on a toolbar.

Thanks

The command you want is:

Rename FROM=* TO={parent} IGNOREEXT

To make a toolbar button: How to use buttons and scripts from this forum

Alternatively, right-click menus can be edited via Settings > File Types > All Files > Context Menu.

Edit: That will work on all files and folders, whether selected or not. To only change what's selected:

Rename PATTERN=* TO={parent} IGNOREEXT

Many thanks for your quick reply Leo. I tested it or and it works great in normal view. However, if I switch on Flat View it fails. It sends to pick a different parent folder name and throws up an error.

It works fine in Flat View here.

What won't work is if you try to select more than one file (with the same extension) in any particular folder, since it would want to rename both files to the same name. But that's what you specified?

Hi Leo,

I think I have discovered the problem(s) and I may not have explained myself correctly the first time:

Say I have a folder structure as follows:

C:\TV\ProgramName S01E10\ABCDEFGH123.mkv
C:\TV\ProgramName S01E10\ReadMe.txt
C:\TV\ProgramName S01E10\ReadMeAgain.txt

C:\TV\ProgramName S02E06\QWPOIHJ09.mkv
C:\TV\ProgramName S02E06\ReadMe.txt

C:\TV\ProgramName S07E05\What's in a name.mkv
C:\TV\ProgramName S07E05\Blah.txt
C:\TV\ProgramName S07E05\BlahBlah.txt

Now If I go into C:\TV\ProgramName S01E10 and choose a file, DOPUS renames one file and fails on the second .txt file. I only want it to rename the selected file (in this case the MKV file and not the .txt files). My workaround to this was to add: WHENEXISTS=skip

Another issue is that if I use Flat View from 'C:\TV' and choose 'Mixed (no folders), then select all the *.MKV files then it renames the first file to 'TV' and tries to do the same for all other files and fails. I can kind of see the logic of why it would do this but is there a way around it? Of course it's very plausible that I doing something wrong here!

Thanks once again.

Ah, I see what you mean. Change FROM to PATTERN and it will only act on the selected files.

Excellent, thanks very much Leo.