Keeping chronological order of folders with deviant "created" time

If the folder names include the dates/times, you could set their created times based on the names (there are a few threads/scripts on the forum for doing that, I think; it's come up before). Or you could have a custom column that turns their names into a date column which you can sort by (but that seems worse than fixing the dates once and using the normal column).

Oh, ok. I must have missed those topics. I will have a look into the forum search. I come back to this thread in case i can't find them. Thanks!

Edit, here's what i found. Is that the one?

Not quite sure what you want to do, but this looks like a better start:

Look promising. Would it be possible to alter the date format to dd-mm-yy? I don't know, if it#s sufficient to just shorten all yyyy's.

Another question, does it handle localized months?

Than you too, lxp, i will check that one first then.

Here's one I was thinking of, for setting the timestamps:

That sets the modified timestamp, but just change "modified" to "created" in the script.

You'll also need to change the regex to match whatever the date format your filenames have is (which you'll need to do whichever solution you go with).

Ok, yet another hack. I will look into it, although the other script aso offers some interesting features. Maybe i can se both? I will check them out.

There's nothing bad or hacky about the newer script there. It extracts the dates from the names and then uses them to set the datestamps on the files/folders.

(The older version of it that used rename scripts was a hack, but that got replaced a long time ago.)

This seems to be the date format:


But i don't understand why it is all "d"s (like it's all days). My target format would be dd-mm-yy, where yy is ommiting the century, like 18-Aug-20.

I had a look into the script, but i have no idea, which parts to alter. Any hints appreciated!

How would i change it

Oh, sorry, i thought i could use "hack" like in "trick". Of course it's not bad.

1 Like

\d in regular expressions means a digit, i.e. [0-9]. The basic list of regex codes is there:!Documents/Regular_Expression_Syntax.htm

Try (\d\d)-(\d\d)-(\d\d) as the regex and 20$3-$2-$1 as the replacement string.

Or you might need to add some logic to decide if the replacement needs to start with "19" or "20", I guess. (Or just make two versions of the scripts, and do the 19xx folders separately to the 2020 folders. Probably easier!)

Edit: Are your dates using month names, not numbers? If so, that makes it a bit harder, but it's still possible.

Ah, I understand! No problem. The old version was definitely a kludge for sure. :smiley:

Alright, a kludge, i know that word too, now you've reminded me. Anyway, i will check it right away. the 19/20 thing shouldn't be a problem, since i started my photo hobby in 2009 (having even studied photography in the early/mid 90s, but that was the good old film time, with black and white, photo lab and chemicals. Those were the days :slight_smile: ) By that i mean digital photography.

1 Like

Here's what i tried, but nothing happens.

Option Explicit
Function OnClick(ByRef clickData)
	Dim strDateTime, strCommand, selItem, re, cmd

	Set re = new RegExp
	re.IgnoreCase = True
	re.Global = False
	' Name, ignoring extension, should be something like "2011-07-29_082609"
	re.Pattern = "^(\d\d)-(\d\d)-(\d\d)"

	Set cmd = clickData.func.command

	For Each selItem in clickData.func.sourcetab.selected
		If (re.Test(selItem.name_stem_m)) Then
			' Set strDateTime to a string like "2011-07-29 08:26:09"
			strDateTime = re.Replace(selItem.name_stem_m, "20$3-$2-$1")
			' DOpus.Output "DT  = " & strDateTime
			strCommand = "SetAttr FILE=""" & selItem.RealPath & """ MODIFIED=""" & strDateTime & """"
			' DOpus.Output "CMD = " & strCommand
			cmd.RunCommand strCommand
		End If
End Function

What's an example folder name?

The ^ at the start of the regex means it will only match if the date is at the start of the string, which you might not want.

As in the screenshot. The green squares are the correct dates, which i want to transfer to the red squares (which is Erstellt=Created).

What exactly is the string? In "18-Aug-20" is actually is the start of the string, ain't it?

Here is a better screenshot. The left side is meant to be in chronological order, the right side is the one which has the wrong "created" stamps (in my example it is a bit exaggerated, though).

but nothing happens.

You need to convert the month names to numbers, either before running the script or in the script.

Is your goal to manipulate the folders' metadata to get the right sorting order? That will never work properly. The only way is to rename the folders into a sortable (ISO) format. The best way to do this is a Rename script.

function OnGetNewName(getNewNameData) {
    var tmpStem = getNewNameData.newname_stem;
    var tmpExt = getNewNameData.newname_ext;

    tmpStem = tmpStem.replace(/(january|januar|jan)/gi, '01');
    tmpStem = tmpStem.replace(/(february|februar|feb)/gi, '02');
    tmpStem = tmpStem.replace(/(march|märz|maerz|mar)/gi, '03');
    tmpStem = tmpStem.replace(/(april|apr)/gi, '04');
    tmpStem = tmpStem.replace(/(may|mai)/gi, '05');
    tmpStem = tmpStem.replace(/(june|juni|jun)/gi, '06');
    tmpStem = tmpStem.replace(/(july|juli|jul)/gi, '07');
    tmpStem = tmpStem.replace(/(august|aug)/gi, '08');
    tmpStem = tmpStem.replace(/(september|sep)/gi, '09');
    tmpStem = tmpStem.replace(/(october|oktober|oct|okt)/gi, '10');
    tmpStem = tmpStem.replace(/(november|nov)/gi, '11');
    tmpStem = tmpStem.replace(/(december|dezember|dec|dez)/gi, '12');

    tmpStem = tmpStem.replace(/(\d\d)-(\d\d)-(\d\d)/gi, '20$3-$2-$1');

    return tmpStem + tmpExt;

36439.orp (1.3 KB)


Sorry, i have no idea how to install the script into the rename section. What is an orp file?