Page 1 of 1
Move files into subfolders
Posted: 30 Jan 2015 00:25
by Got Some Question
Can someone make a script for this?

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]
Re: Request
Posted: 30 Jan 2015 00:56
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.
Re: Request
Posted: 30 Jan 2015 01:03
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!
Re: Request
Posted: 30 Jan 2015 01:07
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
Re: Move files into subfolders
Posted: 30 Jan 2015 01:13
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:)
Re: Move files into subfolders
Posted: 30 Jan 2015 02:27
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;
}