Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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) {
«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 ( (), date ("12/21/2020"))}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment