Help with button to extract dates and change the created date for the folder

Lxp, i found the log now, it was the other one. Looks promising, except i would like to change the created date instead of modified. Is it ok to change

' MODIFIED="' + strDate + '"';

to

' CREATED="' + strDate + '"';

in the 5th last line?

That is already in the previous line :slight_smile:

Don't forget to uncomment :wink:

DOpus.Output(cmdLine);
// cmd.RunCommand(cmdLine);
1 Like

Yep, uncommenting did the trick. Very cool. I can even batch process the folders with your script. If you do this while on your job, i hope your boss doesn't know about it. :wink:

Thanks a lot!

:beers:

Anyone care to point out the "drill"? Please?

Test.

DOpus.Output(cmdLine);
// cmd.RunCommand(cmdLine);

I'm really sorry, but how do I test this?

I guess you can only test it, if you have your folders name in the dd-MMM-yy format AND in the german spelling, which might not be the case, without making some changes to the script.

Just checked your profile, so you can use it, if you're using the german time format like 16-Aug-23.
Suppose, your time stamp is 17-Aug-23, you can use the script, after having placed the script in the Script Addins folder and have uncommented that line (// cmd.RunCommans(cmdLine)). If you then run the SetTimestampsFromFilenameGerman command from the command line or from a button, your created time stamp will be set accordingly to your folder's name.

@abr , thank you for replying. I am so interested in that script, because I recently wrote a "function" (outside of DOpus) transforming various strings into "YYYY-MM-DD" (ISO-format? with RegEx) and will soon be wanting a script within DOpus to transfer

  1. file-names to metadata Title
  2. year to metadata Year

I would really like to learn how to create a script in DOpus. In fact, I would like to also learn how to begin writing a script.

I have what one might call a "Subway Knowledge" of things, like when I moved to Berlin, I knew how to get from A to B, got to know the sourroundings of A and B, and there somewhere was a C. I could reach all these points by subway, but I could not navigate the streets.

I know some HTML, CSS, JavaScript, Regex, and SQL but I struggle to link them together.

I didn't know JScript last year either, but I tested a lot and searched the forum and gradually learned the basics.

Very good, so tell me how I get a first basic script, something like:

myMessage := "Hello World"
alert(myMessage)

Please :smiley:

Itisi, maybe lxp's other script can give you some ideas?

This looks very promising. I will check it. Too late now.

But could someone please tell me how to create this basic script (with the proper commands of course):

myMessage := "Hello World"
alert(myMessage)

And then how to use it in DOpus.

That's how I learned my html, my css. I'll take it from there...
Thank you.

function OnClick(clickData) {
    var dlg = clickData.func.Dlg();
    dlg.title = 'Basic script';
    dlg.message = 'Hello World';
    dlg.buttons = '&OK';
    dlg.show
}
1 Like

Nothing spectacular, just the basic steps. Know how to run a script command, know where to find the logs and how to read them, know how to check if the script will do what you expect it to do, know how to unlock a script (because in its original state, it shoots only blanks for safety).

Thank you all :smiley: @lxp, @abr and @WKen

Nothing spectacular, just the basic steps

Let me try to clarify "the basic steps" (having done some reading)

  1. I write a script (VSCode) and save it with a ".js" extension
  2. I save this script to
    a) %appdata%\GPSoftware\Directory Opus\Script AddIns
    b) %appdata%\Roaming\GPSoftware\Directory Opus\Scripts

Question: Is it a) or b) or either? What is the difference?

  1. Know how to run a script command: link it to a button, menu item

About your script @lxp, what I (later, much later) will try to extract from it is the way you assign values to meta data. (Need to write file-name and year to their respective metadata-fields)

@WKen Your little script will be the seed for all the others. It is straightforward enough to comprehend easily and tinker around with.

@abr your pointing me to "copymeta-copy-metadata-between-files" by @lxp will provide me with the necessary vocabulary

So at last, I will get to know more streets and more connections.

Thank you all very much :smiley:

And here's my favourite quote by Antoine de Saint-Exupéry

The little prince never let go of a question

It's a). b) doesn't exist.

Opus can create the script for you (Preferences / Toolbars / Scripts):

Pasted @WKen's script in a button - et voilà!

hello world

Now I'm trying (so far without success) to activate "HelloNeighbours.js" in the "Scripts" folder and somehow link it to a button. It should display the message "Hello Neighbours"

@lxp, looks like this script doesn't work in V13 anymore. Can you confirm this? I see the modified/created times changed to 00:00, but the folder's name stays unchanged.

Well, this script never tried to rename a folder :thinking:

Sorry, my mistake. I had the wrong test here. It was about the created time stamp only, fixing the chronological order after having folders downloaded from a cloud, which uses to mess up the time stamps. So it still works. I will write a description for that command to the button. Thanks!