Page 1 of 1
Batch Rename: How to prepend parent folder name
Posted: 02 May 2016 20:55
by Jerry
Can't quite figure this out. I'm in branch view and want to prepend to each file name, its parent folder name. So for example, to rename like this:
abc\x --> abc\abc-x
def\y --> def\def-y
Tried <folder>-* but that didn't work. Is there a way to do this currently without scripting?
Re: Batch Rename: How to prepend parent folder name
Posted: 03 May 2016 05:35
by bdeshi
Try
Code: Select all
<prop 'System.ItemFolderNameDisplay'>-*
This will only work in Vista onwards.
SeeCode: Select all
::help "idh_scripting_comref.htm#idh_canonicalproperties";
[/size]
Re: Batch Rename: How to prepend parent folder name
Posted: 03 May 2016 14:47
by Jerry
SammaySarkar wrote:Try
Code: Select all
<prop 'System.ItemFolderNameDisplay'>-*
Thanks! A bit verbose, but it works.
Re: Batch Rename: How to prepend parent folder name
Posted: 03 May 2016 15:00
by bdeshi
Glad to help.
Peter wrote a useful script that returns all available system properties, here:
http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=13397
Re: Batch Rename: How to prepend parent folder name
Posted: 05 May 2016 12:10
by admin
This works as well:
But note that it does not resolve to the folder of each file, but to the current folder. So in a search results list it will probably not give the desired results.
PS: <folder> will work in the next version.
Re: Batch Rename: How to prepend parent folder name
Posted: 05 May 2016 14:24
by highend
PS: <folder> will work in the next version.
Shouldn't it be called <basefolder> then?
Re: Batch Rename: How to prepend parent folder name
Posted: 05 May 2016 14:49
by bdeshi
Why? In my mind <basefolder> is referring some folder common to multiple items, could be probably several levels up.
Re: Batch Rename: How to prepend parent folder name
Posted: 05 May 2016 14:55
by highend
It's just the base folder name. Not something that is a base for every file listed in a pane.
Look at the help file description of getpathcomponent e.g.
For files it's just the file name, no path, no extension. Leave out the extension and you have the same for folders.
Re: Batch Rename: How to prepend parent folder name
Posted: 05 May 2016 15:09
by TheQwerty
But
<folder> is consistent with
<curfolder>.
<basefolder> seems confusing to me because base is typically only meant for getting the name of a file without extension. For a folder its name and base should be the same thing.
Re: Batch Rename: How to prepend parent folder name
Posted: 05 May 2016 15:10
by Jerry
I came across <folder> somewhere in the help file where it was defined as the immediate parent folder name without path. But I can't find it again. I wish information on all relevant properties and syntax were more comprehensive and accessible at the point where you use it. The existing popup syntax help with the "i" button is helpful but doesn't cover the properties. So I still have no confidence about how to use properties in the various places in XYplorer.
Re: Batch Rename: How to prepend parent folder name
Posted: 05 May 2016 15:16
by highend
I came across <folder> somewhere in the help file where it was defined as the immediate parent folder name with path.
One of the reasons it shouldn't be named <folder>. It's ambiguously used (in a lot of applications) as a name for the path. To stay in line what's XYplorer is using name it <curfolder> instead.
Re: Batch Rename: How to prepend parent folder name
Posted: 05 May 2016 15:20
by Jerry
Correction: I saw <folder> defined in the help file as the parent folder withOUT the full path.
Re: Batch Rename: How to prepend parent folder name
Posted: 05 May 2016 15:24
by TheQwerty
highend wrote:I came across <folder> somewhere in the help file where it was defined as the immediate parent folder name with path.
One of the reasons it shouldn't be named <folder>. It's ambiguously used (in a lot of applications) as a name for the path. To stay in line what's XYplorer is using name it <curfolder> instead.
Using <curfolder> can't work because that corresponds to the current item's folder only.
<folder> is already used in three places within XY for
Date affix and
Titlebar templates as well as tab captions.
Re: Batch Rename: How to prepend parent folder name
Posted: 10 May 2018 22:45
by kdenn
This is what I've found does a great job.
Shift F2 and insert variable according to the naming pattern you want.
<folder> *
parent-folder filename.ext
<folder>-*
parent-folder-filename.ext
<folder>_*
parent-folder_filename.ext
If you prefer to auto number instead of prepending the original filename use these variables.
For 0-9:
<folder> <#1>
parent-folder 1.ext
<folder>-<#1>
parent-folder-1.ext
<folder>_<#1>
parent-folder_1.ext
Just add zeros to accommodate the number of files in the folder.
<folder> <#01>
parent-folder 01.ext
<folder>-<#001>
parent-folder-01.ext
<folder>_<#0001>
parent-folder_0001.ext
~Karen
Re: Batch Rename: How to prepend parent folder name
Posted: 11 May 2018 05:22
by RalphM
Welcome to the forum and you successfully resurrected an old thread from 2016.
FYI there are quite a few examples on this in the help file.