This button will rename the parent folder to the same name as the selected file/folder (excluding file extension):
<?xml version="1.0"?>
<button backcol="none" display="label" textcol="none">
<label>Rename Parent Folder</label>
<tip>Rename the Parent Folder to the same name as the Selected File/Folder</tip>
<icon1>#newcommand</icon1>
<function type="normal">
<instruction>@firstfileonly</instruction>
<instruction>Rename {filepath$|..|noterm} TO {file$|noext}</instruction>
</function>
</button>
This button will rename the selected file/folder to the same name as the parent folder:
<?xml version="1.0"?>
<button backcol="none" display="label" textcol="none">
<label>Rename File to Parent</label>
<tip>Rename the Selected File/Folder to the same name as the Parent Folder</tip>
<icon1>#newcommand</icon1>
<function type="normal">
<instruction>Rename TO="{parent}.{ext}" FILEINFO </instruction>
</function>
</button>
Click here if you don't know how to add the buttons to your toolbars.
Hi, these functions will be very usefull but it missing for renaming multiples files from a Parent Folder Name, so a RegEx rename command with a counter can be seriously usefull.e.g: "name_of_previous_folder-01.jpg","name_of_previous_folder-02.jpg","name_of_previous_folder-03.jpg"...
it Gives a function button like that:
<?xml version="1.0"?>
<button display="both" label_pos="right" separate="yes">
<label>Rename by Parent Folder Name and Counter</label>
<tip>Changes files by Parent Folder Name and Counter</tip>
<icon1>16</icon1>
<function type="normal">
<instruction>Rename REGEXP PATTERN "(.*)\.(.*)" TO "{parent}-[#].\2" FILEINFO NUMBER=01 </instruction>
</function>
</button>
Please give us more info on what you are trying to do.
How have you already got the list of those 1000s of files, either in a file collection or in a filtered flat-view window? Or do you need to work out a way to do that first?
What is the criteria for knowing which file within a folder should be used as that folders name (instead of some other file within the same folder)?
All the folders have only one file inside.
I can create a search and get all the files in a lister. Now I want to rename the parent folders of each file to the respective file names.
Whats the best way to do that?
dopusrt /cmd Rename {filepath$|..|noterm} TO {file$|noext}
i.e. Same as the first button/command in the thread, except:
@firstfileonly removed, so that it acts on all selected files, not just the first one.
(In a normal directory, it makes sense to ignore any accidental extra selections, since the one-and-only parent folder can only be renamed to one of the file's names, but that doesn't apply for what you're doing with multiple files in different folders.)
dopusrt /cmd added to the start of the line.
(This is a workaround/kludge. Without it, the first directory gets renamed automatically but then the Rename window appears for the others. Using "dopusrt /cmd" changes when the {file$} etc. arguments are turned into actual filenames, which avoids whatever is causing the problem.)
The command should be run with the files selected, and will then rename those files' parent directories.
Hi, thanks for the great function. By the way, is there any way to 'add' the name of the parent folder 'in front' of the selected file/folder name, rather than just renaming the file?