How to determine iMacros folder locations from Javascript

Moderator: iMacros Moderators

How to determine iMacros folder locations from Javascript

by Tom, Tech Support on Fri Jun 07, 2013 5:32 am

Have you ever wanted to be able to reference the various iMacros folders from your script?

You can add the following function to your Javascript code to easily retrieve these folder locations:

Code: Select all
function getiMacrosFolder(folderName)
{
   var pname;
   switch (folderName)
   {
      case "Macros" :
         pname = "defsavepath";
         break;
      case "DataSources" :
         pname = "defdatapath";
         break;
      case "Downloads" :
         pname = "defdownpath";
         break;
      case "Logs" :
         pname = "deflogpath";
         break;
      default :
         throw folderName + " is not a valid iMacros folder name";
         break;
   }
   return imns.Pref.getFilePref(pname).path;
}

Just pass in the name of the folder to retrieve the full path, for example:

Code: Select all
var downloadFolder = getiMacrosFolder("Downloads");
Regards,

Tom, iMacros Support
Tom, Tech Support
 
Posts: 3300
Joined: Mon May 31, 2010 9:59 am

Return to How-To's and Examples for Firefox / JavaScript Scripting

Who is online

Users browsing this forum: No registered users and 1 guest

-->