Batch Rename: How to prepend parent folder name
-
Jerry
- Posts: 835
- Joined: 05 May 2010 15:48
- Location: The UnUnited States of America
Batch Rename: How to prepend parent folder name
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?
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?
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB. SCREEN SCALING: 125%
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: Batch Rename: How to prepend parent folder name
Try
This will only work in Vista onwards.
See[/size]
Code: Select all
<prop 'System.ItemFolderNameDisplay'>-*See
Code: Select all
::help "idh_scripting_comref.htm#idh_canonicalproperties";Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
Jerry
- Posts: 835
- Joined: 05 May 2010 15:48
- Location: The UnUnited States of America
Re: Batch Rename: How to prepend parent folder name
Thanks! A bit verbose, but it works.SammaySarkar wrote:TryCode: Select all
<prop 'System.ItemFolderNameDisplay'>-*
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB. SCREEN SCALING: 125%
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: Batch Rename: How to prepend parent folder name
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
Peter wrote a useful script that returns all available system properties, here: http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=13397
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
admin
- Site Admin
- Posts: 66725
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Batch Rename: How to prepend parent folder name
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.
Code: Select all
<curfolder>-*PS: <folder> will work in the next version.
FAQ | XY News RSS | XY X
-
highend
- Posts: 15004
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Batch Rename: How to prepend parent folder name
Shouldn't it be called <basefolder> then?PS: <folder> will work in the next version.
One of my scripts helped you out? Please donate via Paypal
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: Batch Rename: How to prepend parent folder name
Why? In my mind <basefolder> is referring some folder common to multiple items, could be probably several levels up.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
highend
- Posts: 15004
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Batch Rename: How to prepend parent folder name
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.
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.
One of my scripts helped you out? Please donate via Paypal
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: Batch Rename: How to prepend parent folder name
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.
<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.
-
Jerry
- Posts: 835
- Joined: 05 May 2010 15:48
- Location: The UnUnited States of America
Re: Batch Rename: How to prepend parent folder name
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.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB. SCREEN SCALING: 125%
-
highend
- Posts: 15004
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Batch Rename: How to prepend parent folder name
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.I came across <folder> somewhere in the help file where it was defined as the immediate parent folder name with path.
One of my scripts helped you out? Please donate via Paypal
-
Jerry
- Posts: 835
- Joined: 05 May 2010 15:48
- Location: The UnUnited States of America
Re: Batch Rename: How to prepend parent folder name
Correction: I saw <folder> defined in the help file as the parent folder withOUT the full path.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB. SCREEN SCALING: 125%
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: Batch Rename: How to prepend parent folder name
Using <curfolder> can't work because that corresponds to the current item's folder only.highend wrote: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.I came across <folder> somewhere in the help file where it was defined as the immediate parent folder name with path.
<folder> is already used in three places within XY for Date affix and Titlebar templates as well as tab captions.
-
kdenn
- Posts: 1
- Joined: 10 May 2018 22:25
Re: Batch Rename: How to prepend parent folder name
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
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
-
RalphM
- Posts: 2122
- Joined: 27 Jan 2005 23:38
- Location: Cairns, Australia
Re: Batch Rename: How to prepend parent folder name
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.
FYI there are quite a few examples on this in the help file.
Ralph 
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)
XYplorer Beta Club