Sorting dd mm yyy date

This is precisely what Opus does but simpler. DropIt is free I presume!!!

This is precisely what Opus does but simpler. DropIt is free I presume!!![/quote]

Well if you know a way of doing this with DOpus, I am all ears!

All the DOpus suggestions so far have involved renaming.

This is precisely what Opus does but simpler. DropIt is free I presume!!![/quote]

Well if you know a way of doing this with DOpus, I am all ears!

All the DOpus suggestions so far have involved renaming.[/quote]
I'm sure if you link your account Leo will help you out.

I'm sure Leo would have said if he knew a way to do this without renaming the files. He kindly offered to help with a way of renaming the files but that is what I want to avoid.

I've locked the thread since you won't link your account and we're going around in circles.

Thank you for linking your account.

So, if you still want to do this using Opus, there are several approaches and which is best will depend on exactly what you to do.

The one I would use is the one I suggested earlier:

You can also set file modification times based on details from the filename to then sort by those details.

(A technique for doing that is here, although it will need slight modification for the different filename formats. It uses a rename script but it won't actually rename the files; it just uses the script to do other things. I can modify the script if needed.)

That way you can view the original files sorted by the dates in their filenames, without creating shortcuts to them, moving/renaming them, or creating an HTML file. But it will modify their file dates.

Is that what you want, or do you need the HTML file and/or need the file dates to remain as they are?

If you need either of those (or something else), then we should be able to make a solution which accommodates them as well, but before we start suggesting things in detail it's good to know exactly what the requirements are.

Before the original message thread hit the buffers, you wrote

I know that this can be confusing, but you can use the "rename" function to do things other than change the name of the file.

In the Opus sense, "rename" means changing the complete name as your PC sees it, including the path. So you can keep the filename the same but change the path.

In other words, you can move files to new directories while maintaining the original name. For example, I use rename scripts to move files based on their "metadata", such as the shooting date for a picture or the disk number for an audio. The name stays the same but the file goes to where I want it.

In calmer times, you wrote:

[quote="michaelkenward"]I realise that I am not answering your question – an annoying habit of people who think the world should be the way they like it – but as someone who has 000,000s of PDF files, many of them filed by date, I can say that you are going to have a hard time sorting those files. Been there, done that.

The good news is that Opus has ways of easing the renaming process to create dates in this format 2012-11-25. This is the universally recognised date code (except in the US) that works fine.

So, if you can bring yourself to renaming the files, life will suddenly be a lot simpler for you.[/quote]

I appreciate the suggestion of renaming the files to yyyy-mm-dd, but there are particular reasons why I do not want to do this. To cut a long story short, it is because the filename is to be used later on for display purposes – e.g. printed at the bottom of each page of a document, listed in an index, etc. and the people reading it will expect dd-mm-yyyy format.

It may well be that the world would be a better place is everyone used yyyy-mm-dd format and, perhaps, one day that will happen. After all, we no longer write “10 minutes past 9” but rather 09.10, so perhaps someday we will all use 2013-12-25. There is an interesting Wikipedia entry showing what different countries apparently do en.wikipedia.org/wiki/Date_format_by_country

But for now, in the context in which this query arises, the file names need to be in the form dd-mm-yyyy…

One other theoretical possibility is to use the Date Modified field – i.e. set it according to the dd-mm-yyyy date at the beginning of the file and then simply list the files by sorting on that column, but, again, that is not suitable for my purposes. One reason is that Windows updates this field. So, for example, you could set the Date Modified using the prefix but then you might modify the file - e.g. it might be a scanned document, scanned in upside down: you rotate and save and that updates the Date Modified. This might sound a trivial problem but it is not just me who will be doing this – I am writing instructions for others many of whom what rather not be using a computer at all – so simplicity is at a premium.

So, to be clear, I want to be able to list files which commence dd-mm-yyyy in chronological order, without renaming them, moving them, or changing the metadata in them.

If you know how to do this in DOpus I would be very pleased to know.

You just commented on not wanting or being able to rename the files to yyyy-mm-dd format, and I can appreciate having reasons you can't do so. But MK's last comments weren't about renaming the filenames themselves, but re-organizing them into date-driven directory structures that would be friendlier to chronological sorting - and probably only came up since that seemed to be something you indicated was an acceptable solution in one of your earlier DropIt examples.

At any rate... there's no method to do what you want simply by clicking an option to sort the way you're asking. So unless GPsoft considers providing such an option, you're left with looking for other means.

If relying on the modified time stamp seems too prone to failure for you because of the possibility of the file being updated, then there are other fields you can consider. For instance, the 'Description' field... You could modify the button Leo provided in the post he linked to in his previous response so that it matches your file naming convention in the regex test:

From: re.Pattern = "^(\d\d\d\d-\d\d-\d\d)_(\d\d)(\d\d)(\d\d)(.[^.]+)$"
To: re.Pattern = "(\d\d)-(\d\d)-(\d\d\d\d)(.*)"

...or something similar or more specific if necessary. Then, the replacement regex:

From: strDateTime = re.Replace(strFileName, "$1 $2:$3:$4")
To: strDate = re.Replace(strFileName, "$3-$1-$2")

...and lastly in the strCommand line, by changing the field that's being set:

From: MODIFIED=
To: DESCRIPTION=

You can then turn on and sort by the Description column.

[quote="steje"]At any rate... there's no method to do what you want simply by clicking an option to sort the way you're asking. So unless GPsoft considers providing such an option, you're left with looking for other means.

If relying on the modified time stamp seems too prone to failure for you because of the possibility of the file being updated, then there are other fields you can consider. For instance, the 'Description' field... You could modify the button Leo provided in the post he linked to in his previous response so that it matches your file naming convention in the regex test...

You can then turn on and sort by the Description column.[/quote]

I have to confess that my knowledge of the seemingly hundreds of metadata field is limited. I don't know what the Description field is or what it is used for. But if it is an additional field provided my DOpus, and therefore free from the possibility of being updated/used by Windows or other software, then that might be a solution. I had said that I did not want to update metadata but if it is a special extra bit of metadata provided just for the purpose, the same objection would not apply.

I'd suggest you put your PDF collection in Flat View mode, then turn on several columns (if you do this very high up in the parent folder structure - this could take a while) to see what you see.

Some likely candidates:

  • Columns->General->Description
  • Columns->General->Label
  • Columns->General->Tags
  • Columns->Documents->Comment

If you don't see any data stored in one of these fields... then it's not currently something you're relying on, right?

Here's a very basic change to the button Leo provided in that other thread. The regex itself probably might need some tweaking to handle unexpected filenames... and I changed the new regex in this button from what I had posted earlier. What I suggested before would have made the Description value a yyyy-dd-mm string - which was an oversight on my part. If you copy the code below, and then just right-click on some empty toolbar space while in Customize mode and select Paste, it'll create a new button on the toolbar.

<?xml version="1.0"?> <button backcol="none" display="both" label_pos="right" textcol="none" type="three_button"> <label>Filename to Desc</label> <icon1>#default:recentlistclear</icon1> <button backcol="none" display="both" label_pos="right" textcol="none"> <label>Filename to Desc</label> <tip>Use a dd-mm-yyyy filename string to set a yyyy-mm-dd Description field value.</tip> <icon1>#default:recentlist</icon1> <function type="normal"> <instruction>Rename PATTERN=&quot;*&quot; TO=&quot;*&quot;</instruction> <instruction>@script vbscript</instruction> <instruction>Option Explicit</instruction> <instruction>&apos; For information on the technique used in this button see:</instruction> <instruction>&apos; &quot;Abusing&quot; Rename Scripts to do other things with file info</instruction> <instruction>&apos; https://resource.dopus.com/t/abusing-rename-scripts-to-do-other-things-with-file-info/5969/1 <instruction>&apos; Change the path below if you haven&apos;t installed Opus to the default location:</instruction> <instruction>dim DOpusRTPath</instruction> <instruction>DOpusRTPath = &quot;%ProgramFiles%\GPSoftware\Directory Opus\dopusrt.exe&quot;</instruction> <instruction>Dim Shell</instruction> <instruction>Set Shell = CreateObject(&quot;WScript.Shell&quot;)</instruction> <instruction>Dim re</instruction> <instruction>Set re = new RegExp</instruction> <instruction>Function Rename_GetNewName(strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName)</instruction> <instruction> Dim strDate</instruction> <instruction> Dim strCommand</instruction> <instruction> &apos; Set strNewName to an empty string so that Opus does not rename the file.</instruction> <instruction> strNewName = &quot;&quot;</instruction> <instruction> re.IgnoreCase = True</instruction> <instruction> re.Global = False</instruction> <instruction> &apos; The strFileName, we have should be something like &quot;29-07-2011 other_filename_text.ext&quot;</instruction> <instruction> re.Pattern = &quot;(\d\d)-(\d\d)-(\d\d\d\d)(.*)&quot;</instruction> <instruction> If (re.Test(strFileName)) Then</instruction> <instruction> &apos; Set strDate to a string like &quot;2011-07-29&quot;</instruction> <instruction> strDate = re.Replace(strFileName, &quot;$3-$2-$1&quot;)</instruction> <instruction> &apos; DOpus.OutputString &quot;DT = &quot; &amp; strDate</instruction> <instruction> strCommand = &quot;&quot;&quot;&quot; &amp; DOpusRTPath &amp; &quot;&quot;&quot; /cmd SetAttr FILE=&quot;&quot;&quot; &amp; strFilePath &amp; &quot;\&quot; &amp; strFileName &amp; &quot;&quot;&quot; DESCRIPTION=&quot;&quot;&quot; &amp; strDate &amp; &quot;&quot;&quot;&quot;</instruction> <instruction> &apos; DOpus.OutputString &quot;CMD = &quot; &amp; strCommand</instruction> <instruction> Shell.Run strCommand,0,true</instruction> <instruction> End If</instruction> <instruction>End Function</instruction> </function> </button> <button backcol="none" display="both" label_pos="right" textcol="none"> <label>Clear Desc</label> <icon1>#default:recentlistclear</icon1> <function type="normal"> <instruction>SetAttr SETDESCRIPTION</instruction> </function> </button> </button>
It's actually a three-button button - and I'd suggest you copy some of your files to test it against the copies:

Left mouse click will: use a dd-mm-yyyy string in the filename, reverse it to yyyy-mm-dd, and then store that new string in the Description field of the file(s).
Right mouse click will: clear the Description field of the selected file(s).

Note: the left click action on this button will overwrite any value already in the Description field.

If there is some other field that seems better for you to use, then you will need to modify the button a bit further. I.e. replace the DESCRIPTION= argument with the appropriate argument for whatever field you find suits your needs if not Description.

[quote="steje"]I'd suggest you put your PDF collection in Flat View mode, then turn on several columns (if you do this very high up in the parent folder structure - this could take a while) to see what you see.

Some likely candidates:

  • Columns->General->Description
  • Columns->General->Label
  • Columns->General->Tags
  • Columns->Documents->Comment

If you don't see any data stored in one of these fields... then it's not currently something you're relying on, right?

[/quote]

That is a very practical approach but what I am planning to do (if I can find a solution) is to write this up and provide it to many people who have differing levels of computer expertise. So I don't want to say to them that they should check their PDF collections, choose a suitable unused metadata field, update this script etc. etc.

Instead I would like to be able to say: here is a script which is available at the DOpus site - it uses the Description field because that is not normally used for anything else....

So I would like to be reasonably sure in my own mind that the Description field is not normally used (obviously there are exceptions to everything). Would it be fair to say, do you think, that the general purpose of the Description field is to insert a description of the file but that because there are now very few restrictions on what can be used as a file name, and on the length of filenames, people tend to put a sufficient description in the file name such that there is seldom any need to use the Description field?

[quote="jjantell"]That is a very practical approach but what I am planning to do (if I can find a solution) is to write this up and provide it to many people who have differing levels of computer expertise. So I don't want to say to them that they should check their PDF collections, choose a suitable unused metadata field, update this script etc. etc.

Instead I would like to be able to say: here is a script which is available at the DOpus site - it uses the Description field because that is not normally used for anything else....[/quote]
I wasn't suggesting you go ahead and give other people work to do in order to figure out what different fields might be available for use :slight_smile:. I was telling YOU to do this work for them in order to determine what was a sensible field to use for your purpose, and then use the same field for everyone. Once you figure out what field might best be used for your common purpose, we can help you quickly arrive at the "here is a script which is available at the DOpus site" part of things... You could just create your own new topic in the Buttons & Toolbars section of these forums, and describe what your pals would need to do in order to install the sort of button we'd help you create, as well as how and when to use it.

I don't think any conjecture about trends of filenames vs the use of description fields, etc makes much sense here. If anything, I'd actually suggest to you that not many people at all use extended metadata or attribute fields. I think those that do are probably more often than not HOME users as opposed to people in a work environment (though some places use applications configured to automatically make use of certain meta fields for certain filetypes). With that in mind - I'd still recommend making the effort (and trivial effort at that) to peruse the collection of docs you and your people have this need for to make a simple inspection of whether or not any of those fields have any data in them. Even if they do, people may not actually be intentionally using them for anything. But certainly if you find a field that is predominantly empty across the set of files, then it wouldn't seem to be important to anybody and I'd consider it fair game to use. Either way, you should base your decision off of what you see happening (or not happening) in your own dataset rather than an arbitrary opinion offered up by me or anyone else outside of your group.

Quite frankly, and I know you don't want to do this from your comments so far... but the more we talk about dealing with other users who aren't computer savvy... the more I'm inclined to convince you to NOT use the methods we're suggesting here. As new files are inserted into your dataset, I'm assuming you're going to need these non-savvy users to use the sort of technique we're exploring here. While it's simple enough to do, it will require ongoing action on the part of your users. It won't matter how simple it is to use if people just don't keep on top of things - they will then have potentially unexpected results from time to time. On the other hand, the most redneck, hillbilly, banjo-twangin American in the world should be able to easily understand a change in filename convention from dd-mm-yyyy to yyyy-mm-dd :slight_smile:.

[quote="steje"]
I wasn't suggesting you go ahead and give other people work to do in order to figure out what different fields might be available for use :slight_smile:. I was telling YOU to do this work for them in order to determine what was a sensible field to use for your purpose, and then use the same field for everyone....

I don't think any conjecture about trends of filenames vs the use of description fields, etc makes much sense here... Either way, you should base your decision off of what you see happening (or not happening) in your own dataset rather than an arbitrary opinion offered up by me or anyone else outside of your group. [/quote]

This is all fair comment but the thing is that the "other people" are future people: people I don't yet know the identity of, so can't ask them (at this point in time) to check their files. I have checked my own files, though, and Description is not used so this seems to be a safe bet (in my opinion - not asking anyone else to stick their neck out).

And thank you for the script, which I have tried out. One thing, though, would it be possible to get it, as well as generating the Description field data, to also set the Description field to be the sort field - one click for everything?

I'd love to believe that, but the USA's nonsense way of recording dates suggests that many people may not agree with you.

How the heck do you support anything that places the date, month and year in a weird sequence?

It isn't dd-mm-yyyy that is the problem but mm-dd-yyyy.

The link to Date format by country on wikipedia is entertaining. It shows that the US is in good company. The other nations that use this convention are Palau, Federated States of Micronesia, Canada and Belize.

Anyone who really wants to make life easy would do as you suggest. But a century or so of craziness won't change overnight.

Why go for the easy option when you can indulge in an intellectual exercise?

I enjoyed that reflection, Michael. :smiley:

I am getting some intermittent problems with the script.

It works fine for a small number of PDFs but when you try it on, say 100 PDFs, it does some, say 40, and then DOpus ends - no error message but program just ends.

@michaelkenward: yeah, I "get it"... Americans do things weird. I'm an American, and it's really not a "many people may not agree with" me sort of thing so much as simply a learned behavior. My point was - at the end of the day, the selfsame ~american users who might otherwise have the mm/dd/yyyy convention stuck in their brain need look no further than the exact situation that the OP is trying to solve in order to understand why it's friendlier to the purpose of sorting to name files in yyyy-mm-dd convention rather than what we've grown up being used to. Further to the point I was commenting that even if such users don't appreciate the benefit of doing so, compared to the relative "hassle" of having to take manual action in order to see the sorting in a way that makes sense... as obstinate as we can be in our ways, the most unreasonable of us should be able to agree that getting used to a more sensible naming convention should be an easier alternative to having to take manual action after the fact every time a new file is added to a dataset.

Whatever...

@jjantell: I can't imagine a reason why you'd be seeing what you're seeing. It might just be a column refresh thing though? If you hit to refresh the lister - do you see the values populate for the files that appear to have been missed?

About setting the sort to the Description column. I wouldn't imagine that you want to do that in a button that sets the description.. .since that's something you'd probably only want to run infrequently. I rather imagine you'd want something independent from a button that sets the Description value. If the users who need this sorting have static folder paths where they need to sort on Description, then you could save the sorting in a folder format for either the specific folder paths in scope - or using a wildcard pattern format if you have some unique folder names somewhere in the path to these folders. You could also set a content type folder format... which, if the folders that you'd need this sorting primarily contain PDF files only - you create a content type format for some high percentage of PDF files that would trigger the sort on Description. Shout if you want help figuring out what that means...

[quote="steje"] I can't imagine a reason why you'd be seeing what you're seeing. It might just be a column refresh thing though? If you hit to refresh the lister - do you see the values populate for the files that appear to have been missed?

About setting the sort to the Description column. I wouldn't imagine that you want to do that in a button that sets the description.. .[/quote]

Just to be clear: it is not just the script ending but the whole Opus program ends with no error message.

when you restart OPus only some of the files are populated.

With regard to setting the sort to the Description column, I would like to make the button as user-friendly as possible so that users only need to know that if they press the button the files will sort on date. That may mean setting sort more often than you need but that doesn't do any harm.

On further reflection, I think you are right about sorting the Description field. You don't want to repopulate unnecessarily every time you open a folder whose contents have not changed just to get the sorting set, so necessarily the user will be saving the folder format with e.g. Folder Options and this doesn't need to be done in the button.

So the button does what we want...

...apart from the fact that DOpus terminates part way through.