Article View: adobe.scripting.indesign
Article #2639Problem with File.copy() -- should this work?
From: Dave_Saunders
Date: Sat, 13 Dec 2008 02:18
Date: Sat, 13 Dec 2008 02:18
29 lines
1669 bytes
1669 bytes
I'm trying to copy a number of script files (I'm testing with just one) out of one folder into another. Here's the code:
(function() {
var myFolder = Folder(getScriptPath().parent + "/disabled");
if (myFolder.exists) {
var myScripts = myFolder.getFiles("*.jsx");
for (var j = 0; myScripts.length > j; j++) {
if (myScripts[j].copy("../enabled")) {
myScripts[j].remove();
}
}
}
function getScriptPath() {
// This function returns the path to the active script, even when running ESTK
try {
return app.activeScript;
} catch(e) {
return File(e.fileName);
}
} // end getScriptPath
}())
What's happening is that the file in the disabled folder is simply being deleted. This means that the copy method is returning true and yet the copy didn't happen. Perhaps my URI is wrong, but if so, the copy should have failed. The file is not in either the InDesign or ESTK packages, which seem to be the only two worth looking in -- I was running from ESTK with InDesign CS4 targeted.
Dave
Technical Details
Message-ID:
<59b741e0.-1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f939a,42a64b28108c0aee,start X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Problem with File.copy() -- should this work? Message-ID: <59b741e0.-1@webcrossing.la2eafNXanI> Date: Fri, 12 Dec 2008 18:18:50 -0800 Lines: 35 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit