Batch flatten folder

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Theodecarvalho
Posts: 49
Joined: 17 Jul 2022 11:59

Batch flatten folder

Post by Theodecarvalho »

How can I easily batch flattenfolder?

I just want to select a bunch of folders and XY flatten to my root folder. I wanna to flatten on inside the folders that I selected. Not one by one

Like this:

Root (where I am)
- [asset 01]
--- [maps]
------ file 01
------ file 02
--- [example]
----- file 03
----- file 04
- [asset 02]
--- [maps]
----- file 05
----- file 06
--- [example]
----- file 07
----- file 08

I want to compact, selecting folders [asset 01] and [asset 02] and flatten inside, like this:
- [asset 01]
--- file 01
--- file 02
--- file 03
--- file 04
- [asset 02]
--- file 05
--- file 06
--- file 07
--- file 08

admin
Site Admin
Posts: 67337
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Batch flatten folder

Post by admin »

Check out "Flatten Folder" here: Configuration | General | Menus, Mouse, Usability | Context Menus | File List...

Not entirely sure what you want, so make some tests before you start the serious stuff.

Norn
Posts: 522
Joined: 24 Oct 2021 16:10

Re: Batch flatten folder

Post by Norn »

It's in the 32-bit context menu. . .
To see the attached files, you need to log into the forum.
Windows 11 24H2 @100% 2560x1440

admin
Site Admin
Posts: 67337
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Batch flatten folder

Post by admin »

Ah yes.

For those using the 64-bit context menu there is also a scripting command flattenfolder().

Theodecarvalho
Posts: 49
Joined: 17 Jul 2022 11:59

Re: Batch flatten folder

Post by Theodecarvalho »

admin wrote: ↑21 Jul 2022 16:19 Check out "Flatten Folder" here: Configuration | General | Menus, Mouse, Usability | Context Menus | File List...

Not entirely sure what you want, so make some tests before you start the serious stuff.
I want to flatten several folders, but keeping the root of each one. I mean... I need to batch the flaten folder command to hundreds of folders.

If I use the tree, flatten folder appears. But I cant select more than one. (This is my try to batch)
08.jpg
If I select one or several folders, I cant batch flatten folder, it wont appear
09.jpg
btw, flatten is turned on. I looked for an old post explaining the procedure.
10.jpg
.

I thinks its simple, for you, just use flatten folder to a hundreds of folders (without combine them).

Thanks.
To see the attached files, you need to log into the forum.

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

Re: Batch flatten folder

Post by highend »

A simple script does that^^

Code: Select all

    $roots = regexmatches(<get SelectedItemsPathNamesSlashed>, "^.*?\\$", <crlf>);
    end (!$roots), "No folder(s) selected, aborted!";

    showstatus 0;
    $cntRoots = gettoken($roots, "count", <crlf>);
    while ($i++ < $cntRoots) {
        $root = gettoken($roots, $i, <crlf>);
        status "Flattening $i / $cntRoots", , "progress";
        flattenfolder($root, "n");
    }
    status "All flattening done...";
One of my scripts helped you out? Please donate via Paypal

Theodecarvalho
Posts: 49
Joined: 17 Jul 2022 11:59

Re: Batch flatten folder

Post by Theodecarvalho »

Thanks. It works when I run "try script"

I saved in BATCHFLATTENFOLDER.XYS and now im struggling to make it easy access, even in context menu or Catalog.

I found this topic: viewtopic.php?t=3613 from 2009, but I tried several lines and none worked :(

load "D:\PROGRAMAS\XYplorer 23.00.0100\BATCHFLATTENFOLDER.XYS";
::load "D:\PROGRAMAS\XYplorer 23.00.0100\BATCHFLATTENFOLDER.XYS";
::load 'D:\PROGRAMAS\XYplorer 23.00.0100\BATCHFLATTENFOLDER.XYS';

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

Re: Batch flatten folder

Post by highend »

Screenshot from the properties of that catalog entry?
Screenshot of the full file location of the .xys script?
One of my scripts helped you out? Please donate via Paypal

Theodecarvalho
Posts: 49
Joined: 17 Jul 2022 11:59

Re: Batch flatten folder

Post by Theodecarvalho »

highend wrote: ↑21 Jul 2022 21:05 Screenshot from the properties of that catalog entry?
Screenshot of the full file location of the .xys script?
11.jpg
12.jpg
To see the attached files, you need to log into the forum.

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

Re: Batch flatten folder

Post by highend »

The Action on Click must be "Go to Location", not "Open item"
One of my scripts helped you out? Please donate via Paypal

Theodecarvalho
Posts: 49
Joined: 17 Jul 2022 11:59

Re: Batch flatten folder

Post by Theodecarvalho »

highend wrote: ↑21 Jul 2022 21:54 The Action on Click must be "Go to Location", not "Open item"
Thanks! It almost works flawless.

When I use it with a few folders, works fine. But, sometimes, when I got several folders (I didn´t identify the amount preciselly) It appears an error:
13.jpg
BTW: I got travel for work, so I couldn´t test before I come back.
To see the attached files, you need to log into the forum.

Post Reply