Move files into subfolders

Discuss and share scripts and script files...
Post Reply
Got Some Question
Posts: 11
Joined: 01 Jul 2014 15:07

Move files into subfolders

Post by Got Some Question »

Can someone make a script for this?
Image
when you got a folder: that contains files from diffrend dates.
then when click the button the script would set each file to a new created map called like the date of the file.
so they are sorted in folders

i have no idea about scripting but if someone can it would be great.

[Title modified]

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Request

Post by PeterH »

Just to the concept: you want to name the folders like dd-mm-yyyy :?:
Wouldn't it be better, just for sorting, to name them yyyy-mm-dd :?:

I even create main folders yyyy, with subfolders mm-dd - but that seems to be a matter of taste.

By the way: I think it would be better to take the date from "Picture Taken" than from Created. As "Created" can be modified, e.g. for on operations.
Win11 Pro 223H2 Gerrman

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

Re: Request

Post by highend »

Code: Select all

    foreach($file, listpane(, , 1)) {
        moveto regexreplace(regexmatches(property("#date.c", $file), "^[^\s]+"), "\/\\", "-"), $file, , 2;
    }
It just does what you asked for (at least it should do)... Test it!
One of my scripts helped you out? Please donate via Paypal

Got Some Question
Posts: 11
Joined: 01 Jul 2014 15:07

Re: Request

Post by Got Some Question »

Uhm Yeah yyyy-mm-dd is actually better thnx:)
And "Picture taken" is also great:) i have no idea what the options are thats why i ask it to smart guys in this language:P
But i really dont like to sort it manually. And if its possible i wanted to say really thnx:P

Got Some Question
Posts: 11
Joined: 01 Jul 2014 15:07

Re: Move files into subfolders

Post by Got Some Question »

indeed The begin works great :) but when i make a test map and copy some files to the folder it get all the same date so they putted in the same folder.
but when i look by "modified" i see diffrends dates. so i think your idea is a lot better:)

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

Re: Move files into subfolders

Post by highend »

I assume that you want at least fall back to the created date if there isn't any exif date?

If that's the case, this should work...

It's only valid for date formats like
day.month.year
day-month-year
day/month/year

Code: Select all

    foreach($file, listpane(, , 1)) {
        // Exif date (pictures)
        if regexmatches(getpathcomponent($file, "ext"), "jpg|jpeg|tiff") {
            $date = property("#image.datetaken", $file);
        }

        if (!$date) {
            // Switch to creation date if exif date not found
            $date = property("#date.c", $file);
        }

        // Change date to yyyy-mm-dd
        $date = regexreplace($date, "^(\d+)(?:\.|-|/)(\d+)(?:\.|-|/)(\d+)(.*)", "$3-$2-$1");

        moveto $date, $file, , 2;
    }
One of my scripts helped you out? Please donate via Paypal

Post Reply