FYI, this is how I worked around it.
I need to download a series of files from Google WebMaster Tools [for each client; one client demonstrated here], then copy each to a server folder, then move each into a local storage folder for safe keeping.
In a text file, I listed the elements for each file: it's web page ID, it's local folder, and it's server folder:
http://joy.com /Users/cameron/Data/project/myagency/joy/links/ /Volumes/project/myagency/joy/links
http://www.joy.com /Users/cameron/Data/project/myagency/joy/links/ /Volumes/project/myagency/joy/links
https://www.joy.com /Users/cameron/Data/project/myagency/joy/links/ /Volumes/project/myagency/joy/links
In the Fake script, I read in each line from the text file and broke it into its various elements using Javascript (I kept some Javascript alerts commented out in the code to easily peek at the values during development):
-- Do JavaScript
var line = fake.get('line');
var row = line.split('\t');
fake.set('domain',row[0]);
fake.set('localpath',row[1]);
fake.set('serverpath',row[2]);
// window.alert('domain=' + fake.get('domain'));
// window.alert('localpath =' + fake.get('localpath'));
// window.alert('serverpath =' + fake.get('serverpath'));
// now strip http, https, and replace periods with hyphens
fake.set('fileprefix', fake.get('domain').split("http://").join(""));
fake.set('fileprefix', fake.get('fileprefix').split("https://").join(""));
fake.set('fileprefix', fake.get('fileprefix').split(".").join("-"));
// window.alert('fileprefix=' + fake.get('fileprefix'));
// fileprefix should be joy-com and www-joy-com
Then, using an Applescript that accesses [some of] those variables, I did the copy and the move (again, I kept some diagnostic code in place for easy Applescript testing in Script Debugger):
-- Run Applescript:
-- set targetLocalPath to "/Users/cameron/Data/project/myagency/joy/links/"
-- set targetServerPath to "/Volumes/project/myagency/joy/links/"
-- code specific to Fake (uses Fake variables extracted with Javascript)
set targetLocalPath to "${localpath}"
set targetServerPath to "${serverpath}"
tell application "Finder"
-- create source folder if necessary
set volumeName to boot volume of (system info)
set TransfersFolder to alias (volumeName & ":Transfers:")
if (exists (folder "google metrics") of TransfersFolder) is false then
set sourceFolder to (make new folder at TransfersFolder with properties {name:"google metrics"})
else
set sourceFolder to folder "google metrics" of TransfersFolder
end if
-- create targetLocalFolder if necessary
if (not (exists (targetLocalPath as POSIX file))) then
set targetLocalFolder to (make new folder (POSIX file targetLocalPath))
else
set targetLocalFolder to (targetLocalPath as POSIX file)
end if
-- create targetServerFolder if necessary
if (not (exists (targetServerPath as POSIX file))) then
set targetServerFolder to (make new folder (POSIX file targetServerPath))
else
set targetServerFolder to (targetServerPath as POSIX file)
end if
-- display dialog "targetServerFolder =" & targetServerFolder
-- set latestGoogleFileAlias to (last file of (sourceFolder) whose name begins with "joy-com") as alias
-- code specific to Fake (uses Fake variables extracted with Javascript)
set latestGoogleFileAlias to (last file of (sourceFolder) whose name begins with "${fileprefix}") as alias
duplicate latestGoogleFileAlias to targetServerFolder with replacing
move latestGoogleFileAlias to targetLocalFolder with replacing
end tell
When I got stuck during this script development, I ended up bumping into my own question from months and months ago, so I thought I'd post this solution in hopes of helping anyone else who might be trying this in Fake.
Hope this helps, Merry Christmas everyone.
Cameron Knowlton