Looking for some XY help in reorganizing hundreds of scanned "CD" asset archive files (Cover,booklet, disc etc) that all have the same name (artwork.rar) and all exist in a folder structure that looks like this:
Album Assets->P-Pink Floyd->The Wall->Artwork.rar
Ideally in XYPlorer - I would like to be able to select any "artwork.rar" file and run a script that instantly renames it based on the name of its current folder (The Wall) and the folder above it (Pink Floyd). Effectively resulting in a file named Pink Floyd - The Wall.rar. Spaces and dash included.
Anyone have anything like this? Or could point me to how to tackle it?
Cheers!
VP
Script that would rename a file based on subfolder?
-
Vocalpoint
- Posts: 178
- Joined: 06 Nov 2009 14:01
Script that would rename a file based on subfolder?
OS: Win 11 25H2 Pro x64 | XY: 27.20.800 (x32)| Display: 1920x1080 @ 60hz
-
highend
- Posts: 14940
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Script that would rename a file based on subfolder?
Haaaaaard!
Code: Select all
if (exists("<curitem>") == 1) { renameitem(getpathcomponent("<curitem>", "parent") . " - " . getpathcomponent("<curitem>", "component", -3)); }One of my scripts helped you out? Please donate via Paypal
-
Vocalpoint
- Posts: 178
- Joined: 06 Nov 2009 14:01
Re: Script that would rename a file based on subfolder?
Wow! Sweethighend wrote:Haaaaaard!Code: Select all
if (exists("<curitem>") == 1) { renameitem(getpathcomponent("<curitem>", "parent") . " - " . getpathcomponent("<curitem>", "component", -3)); }
However - the rename ends up being in reverse. I am getting The Wall - Pink Floyd.rar
What do I need to swap around?
VP
OS: Win 11 25H2 Pro x64 | XY: 27.20.800 (x32)| Display: 1920x1080 @ 60hz
-
highend
- Posts: 14940
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Script that would rename a file based on subfolder?
Guess...
Both getpathcomponents statements?
Both getpathcomponents statements?
Code: Select all
if (exists("<curitem>") == 1) { renameitem(getpathcomponent("<curitem>", "component", -3) . " - " . getpathcomponent("<curitem>", "parent")); }One of my scripts helped you out? Please donate via Paypal
-
Vocalpoint
- Posts: 178
- Joined: 06 Nov 2009 14:01
Re: Script that would rename a file based on subfolder?
I got this one working - but now - I have issues with the Parent folder name has a "dot" in the title. So when I attempt to rename a structure like this:highend wrote:Guess...
Both getpathcomponents statements?
Code: Select all
if (exists("<curitem>") == 1) { renameitem(getpathcomponent("<curitem>", "component", -3) . " - " . getpathcomponent("<curitem>", "parent")); }
B.B. King\Blues Is King\Artwork.rar
Instead of getting:
B.B. King - Blues Is King.rar
I get the right filename but a very weird extension...
B.B. King - Blues Is King.king - blues is king
Any ideas how to prevent a "." in a folder name from being detected as a separator for the extension?
Really appreciate all your help.
Cheers!
VP
OS: Win 11 25H2 Pro x64 | XY: 27.20.800 (x32)| Display: 1920x1080 @ 60hz
-
highend
- Posts: 14940
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Script that would rename a file based on subfolder?
Code: Select all
if (exists("<curitem>") == 1) { renameitem(getpathcomponent("<curitem>", "component", -3) . " - " . getpathcomponent("<curitem>", "parent"), , 1); }One of my scripts helped you out? Please donate via Paypal
-
admin
- Site Admin
- Posts: 66258
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Script that would rename a file based on subfolder?
Would anybody object if I add an alias "gpc" to "getpathcomponent"...? 
FAQ | XY News RSS | XY X
-
highend
- Posts: 14940
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Script that would rename a file based on subfolder?
As long as it's documented, no objection 
One of my scripts helped you out? Please donate via Paypal
-
Vocalpoint
- Posts: 178
- Joined: 06 Nov 2009 14:01
Re: Script that would rename a file based on subfolder?
highend wrote:Code: Select all
if (exists("<curitem>") == 1) { renameitem(getpathcomponent("<curitem>", "component", -3) . " - " . getpathcomponent("<curitem>", "parent"), , 1); }
Awesome! Thanks again!
VP
OS: Win 11 25H2 Pro x64 | XY: 27.20.800 (x32)| Display: 1920x1080 @ 60hz
XYplorer Beta Club