Page 1 of 1

Move files with specific extensions to subfolders

Posted: 13 Sep 2024 16:05
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

Re: Move files with specific extensions to subfolders

Posted: 13 Sep 2024 16:34
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!";

Re: Move files with specific extensions to subfolders

Posted: 16 Sep 2024 13:02
by TomPiXX
Omg! I will give it a try. Thank you so much!