Append folder size to Folder name using the Special Renaming function

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
xyMario
Posts: 11
Joined: 29 Aug 2023 15:27

Append folder size to Folder name using the Special Renaming function

Post by xyMario »

Apparently, according to a boot, there were options in the renamer for custom scripts. I just wast to add the folder size to the folder name a such:
Original:
FOLDER
Change to:
FOLDER 1 [Folder size]
Example: Movies [4], where 4 is 4 gigabytes

Is this possible?

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

Re: Append folder size to Folder name using the Special Renaming function

Post by highend »

Code: Select all

end (exists(<curitem>) != 2), "No folder selected, aborted!";
    $size = foldersize(<curitem>, "<r>");
    $size = replace(formatbytes($size, "GB", "0"), " GB");
    $name = <curname> . " [$size]";
    renameitem($name, <curitem>);
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

xyMario
Posts: 11
Joined: 29 Aug 2023 15:27

Re: Append folder size to Folder name using the Special Renaming function

Post by xyMario »

Thank you for this! Can this be edited to show up to 2 decimal spots: [18.87] and also to work on more than one file at a time?

xyMario
Posts: 11
Joined: 29 Aug 2023 15:27

Re: Append folder size to Folder name using the Special Renaming function

Post by xyMario »

I tried to research this and then just started guessing and to get the 2 decimal points I changed the "0" to "2"

end (exists(<curitem>) != 2), "No folder selected, aborted!";
$size = foldersize(<curitem>, "<r>");
$size = replace(formatbytes($size, "GB", "2"), " GB");
$name = <curname> . " [$size]";
renameitem($name, <curitem>);
Now if I can only figure out how to run it on more than one folder at a time. If I select 2 or more folders it only appends the last folder. :eh:

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

Re: Append folder size to Folder name using the Special Renaming function

Post by highend »

Code: Select all

setting "BackgroundFileOps", 0;
    foreach($item, <get SelectedItemsPathNames>, <crlf>, "e") {
        if (exists($item) != 2) { continue; }
        $size = foldersize($item, "<r>");
        $size = replace(formatbytes($size, "GB", "2"), " GB");
        $name = gpc($item, "file") . " [$size]";
        renameitem($name, $item);
    }
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

xyMario
Posts: 11
Joined: 29 Aug 2023 15:27

Re: Append folder size to Folder name using the Special Renaming function

Post by xyMario »

Thank you so much! :party:

Post Reply