Skip to content

Instantly share code, notes, and snippets.

@scripting
Last active January 17, 2021 12:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scripting/ab9c485db8480cc7eea091f33730aa96 to your computer and use it in GitHub Desktop.
Save scripting/ab9c485db8480cc7eea091f33730aa96 to your computer and use it in GitHub Desktop.
I needed a script to loop over a calendar-structured folder to generate a list of the most recent updates to a set of projects that are backed up in these folders. I used Frontier. Here's the script.
on listChangedProjects (whenStart, whenEnd) {
«Changes
«1/16/21; 10:36:01 AM by DW
«Created. Generates a table with the names of the most recent version of each of the projects that
were edited in the period we're looking at. whenStart is the day we start our search, whenEnd is
when we stop searching. We go back in time, so whenStart must be more recent than whenEnd.
local (basefolder = nodeEditorSuite.getFolder () + "backups:");
local (destfolder = "Marin:changedProjects:");
local (when = whenStart, adrtable = @scratchpad.changedProjects);
new (tabletype, adrtable);
while (when > date (whenEnd)) {
local (subfolder = basefolder + file.getdatepath (":", when));
if file.exists (subfolder) {
fileloop (f in subfolder) {
local (fname = file.filefrompath (f));
local (projectName = string.nthField (fname, ".", 1));
if not defined (adrtable^ [projectName]) {
local (fdest = destfolder + fname);
adrtable^ [projectName] = f;
file.surefilepath (fdest);
file.copy (f, fdest);
file.setmodified (fdest, file.modified (f))}}};
when = date.yesterday (when)};
edit (adrtable);
file.openfolder (destfolder)};
bundle { //test code
listChangedProjects (clock.now (), date ("12/21/2020"))}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment