Skip to content

Commit 15c8646

Browse files
committed
allow folders outside of script folder path
1 parent 46cbf57 commit 15c8646

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

startup scripts/addScriptFolderToMenu.jsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
var px = {
66
projectName: "AddScriptFolderToMenu",
7-
version: "2019-01-31-v1.1",
7+
version: "2019-05-05-v1.2",
88

9-
scriptFolderMenuFolderName: "Scripts Menu",
9+
scriptMenuFolderName: app.scriptPreferences.scriptsFolder + "/" + "Scripts Menu",
10+
// scriptMenuFolderName: "/Users/hp/github/addScriptFolderToMenu/Scripts Menu",
11+
1012
scriptMenuName: localize({ en: "Scripts", de: "Skripte" }),
1113

1214
position: "table", // help
@@ -602,7 +604,7 @@ $.global.hasOwnProperty('idsLog') || (function (HOST, SELF) {
602604
*/
603605
getLogFile: function () {
604606
return logFile;
605-
}
607+
}
606608
}
607609
};
608610
})($.global, { toString: function () { return 'idsLog'; } });
@@ -639,24 +641,24 @@ function main() {
639641

640642
function installMenu() {
641643
// User Folder
642-
var scriptFolderMenuPath = Folder(app.scriptPreferences.scriptsFolder + "/" + px.scriptFolderMenuFolderName);
643-
if (scriptFolderMenuPath.alias) {
644+
var scriptMenuFolderPath = Folder(px.scriptMenuFolderName);
645+
if (scriptMenuFolderPath.alias) {
644646
try {
645-
scriptFolderMenuPath = scriptFolderMenuPath.resolve();
647+
scriptMenuFolderPath = scriptMenuFolderPath.resolve();
646648
}
647649
catch (e) {
648650
log.warn(e);
649-
log.warn("Could not resolve alias. Check your alias file [" + scriptFolderMenuPath + "]");
651+
log.warn("Could not resolve alias. Check your alias file [" + scriptMenuFolderPath + "]");
650652
return;
651653
}
652654
}
653655

654-
if (scriptFolderMenuPath.exists) {
656+
if (scriptMenuFolderPath.exists) {
655657
// analyse scripts in scriptfolder
656658
var scriptsArray = [];
657-
scriptsArray = analyseScriptsFolder(scriptFolderMenuPath, scriptsArray);
659+
scriptsArray = analyseScriptsFolder(scriptMenuFolderPath, scriptsArray);
658660
if (scriptsArray.length == 0) {
659-
log.warn("No script files found in folder [" + scriptFolderMenuPath + "]");
661+
log.warn("No script files found in folder [" + scriptMenuFolderPath + "]");
660662
return;
661663
}
662664

@@ -688,7 +690,7 @@ function installMenu() {
688690

689691
}
690692
else {
691-
log.info("Could not find a Folder [" + px.scriptFolderMenuFolderName + "] in [" + app.scriptPreferences.scriptsFolder + "]");
693+
log.info("Could not find the folder [" + px.scriptMenuFolderName + "]");
692694
}
693695
}
694696

@@ -768,7 +770,7 @@ function analyseScriptsFolder(folder, scriptsArray) {
768770

769771
function checkForChildren(child) {
770772
var children = child.getFiles();
771-
for (i = 0; i < children.length; i++) {
773+
for (i = 0; i < children.length; i++) {
772774
child = children[i];
773775
if (child instanceof Folder && checkForChildren(child)) {
774776
return true;
@@ -855,13 +857,13 @@ function showInfoAndUninstall() {
855857

856858
dialogWin.gText = dialogWin.add("group");
857859

858-
dialogWin.gText.stMsg = dialogWin.gText.add("statictext", undefined, localize({ en: "This menu shows scripts from " + px.scriptFolderMenuFolderName, de: "Dieses Menü zeigt die Skripte aus dem Ordner " + px.scriptFolderMenuFolderName }));
860+
dialogWin.gText.stMsg = dialogWin.gText.add("statictext", undefined, localize({ en: "This menu shows scripts from " + px.scriptMenuFolderName, de: "Dieses Menü zeigt die Skripte aus dem Ordner " + px.scriptMenuFolderName }));
859861
dialogWin.gText.stMsg.maximumSize.height = 300;
860862
dialogWin.gText.stMsg.minimumSize.width = 350;
861863

862864
dialogWin.gText.btOpenFolderLocation = dialogWin.gText.add("button", undefined, localize({ en: "Show folder", de: "Ordner anzeigen" }));
863865
dialogWin.gText.btOpenFolderLocation.onClick = function () {
864-
Folder(app.scriptPreferences.scriptsFolder + "/" + px.scriptFolderMenuFolderName).execute();
866+
Folder(px.scriptMenuFolderName).execute();
865867
dialogWin.close(0);
866868
}
867869

0 commit comments

Comments
 (0)