How to Rename folder as great grandparent folder name

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
aswinrm
Posts: 3
Joined: 26 Aug 2021 06:17

How to Rename folder as great grandparent folder name

Post by aswinrm »

Hello,
I have a dataset which needs to be renamed.
The structurre of folder is as follows.
D:\XXXX\Control\PPMI\3104\MPRAGE_GRAPPA\2011-08-01_13_30_13.0\S120955\######.dcm
S120955 folder needs to changed as 3104 [great grandparent folder name]

Image

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to Rename folder as great grandparent folder name

Post by highend »

Go into the "D:\XXXX\Control\PPMI" folder (and nowwhere else^^) and execute the script...

You'd better do it with some test data, e.g. by duplicating your original folder(s)...
Rename to grandfather + suffix.xys
(1.98 KiB) Downloaded 54 times
One of my scripts helped you out? Please donate via Paypal

RalphM
Posts: 1935
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: How to Rename folder as great grandparent folder name

Post by RalphM »

Hi, welcome to the forum.
Short answer, AFAIK not possible out of the box.
You would need to script this by getting the name of the folder two levels up and then rename the subfolders accordingly.

Edit: Two minutes too slow and there you already got a script done for you.
Ralph :)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)

aswinrm
Posts: 3
Joined: 26 Aug 2021 06:17

Re: How to Rename folder as great grandparent folder name

Post by aswinrm »

highend wrote: 26 Aug 2021 08:19 Go into the "D:\XXXX\Control\PPMI" folder (and nowwhere else^^) and execute the script...

You'd better do it with some test data, e.g. by duplicating your original folder(s)...

Rename to grandfather + suffix.xys
Thanks a lot...

Code: Select all

$firstSub = gpc($item, "component", -($cntRootSep +1));
changed the foldername as PPMI_T1 ....
However when i changed it to "+0 " the script worked as needed...

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to Rename folder as great grandparent folder name

Post by highend »

Replace the line with
$firstSub = gpc($item, "component", -($cntSep - $cntRootSep));
then it should work regardless of depth...

I've reuploaded the script as well
One of my scripts helped you out? Please donate via Paypal

aswinrm
Posts: 3
Joined: 26 Aug 2021 06:17

Re: How to Rename folder as great grandparent folder name

Post by aswinrm »

highend wrote: 26 Aug 2021 09:52 Replace the line with
$firstSub = gpc($item, "component", -($cntSep - $cntRootSep));
then it should work regardless of depth...

I've reuploaded the script as well
Thanks...
Newly uploaded script works perfectly... :appl: :party:

Post Reply