Move files with specific extensions to subfolders

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
TomPiXX
Posts: 23
Joined: 10 Jul 2016 02:09
Location: NRW, Germany

Move files with specific extensions to subfolders

Post by TomPiXX »

Hello community,

I have a request and don't know if it can be realised.
I work as a video editor and regularly have to sort footage into project folders.

The individual .mp4 files are as follows:

Main Folder
├ Project 1
│    ├ Footage
│    ├ footage1.mp4
│    └ footage2.mp4
└ Project 2
     ├ Footage
     ├ footage1.mp4
     └ footage2.mp4


I would now like to automatically move all the footage within the project folders to the respective "Footage" subfolders.
Is this possible? If so, can someone help me with this?


Thanks
Tom

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

Re: Move files with specific extensions to subfolders

Post by highend »

To be executed when you are inside the "Main Folder" or one of the (main) "Project <x>" folder(s)...

Code: Select all

    $videos = quicksearch("*.mp4", , , "s");
    end (!$videos), "No .mp4 file(s) found, aborted!";

    // Skip videos that are (already) in a subfolder named "Footage"
    $videos = formatlist($videos, "f", <crlf>, "!*\Footage\*");

    setting "BackgroundFileOps", 0;
    foreach($video, $videos, <crlf>, "e") {
        // Only move if a subfolder named "Footage" is on the same hierachy level
        $dst = gpc($video, "path") . "\" . "Footage";
        if (exists($dst) == 2) { moveto $dst, $video, , 0, 2, 4, 1, 0, 0, 1, 0, 0; }
    }
    echo ".mp4 file(s) moved!";
One of my scripts helped you out? Please donate via Paypal

TomPiXX
Posts: 23
Joined: 10 Jul 2016 02:09
Location: NRW, Germany

Re: Move files with specific extensions to subfolders

Post by TomPiXX »

Omg! I will give it a try. Thank you so much!

Post Reply