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?
-
- Posts: 163
- Joined: 06 Nov 2009 14:01
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
-
- Posts: 163
- 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
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
-
- Posts: 163
- 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
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
-
- Site Admin
- Posts: 60538
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @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 Twitter
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
-
- Posts: 163
- 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