I'm trying to get a list of AAX plugins that are currently in my ProTools plugz folder:
var sourcePath = '/Library/Application Support/Avid/Audio/Plug-Ins'
var filesInFolder sf.file.directoryGetFiles({ path: sourcePath }).paths.map(x => x.split('/').slice(-1))
But this seems to ignore all the .aaxplugin files and stores all the files that are NOT aax (.xml, .eng, etc).
If I filter by .aaxplugin:
var sourcePath = '/Library/Application Support/Avid/Audio/Plug-Ins'
var filesInFolder = sf.file.directoryGetFiles({ path: sourcePath }).paths.filter(x => x.match('.aaxplugin')).map(x => x.split('/').slice(-1))
Then nothing is stored in the filesInFolder var.
Any thoughts on what I'm doing wrong/how to get the AAX plugins into a var? My end goal is to have a script that will take a list of plugins that I give it, ensure those are in the Plugins folder, and move everything else to unused.
Thanks!
- Chris Shaw @Chris_Shaw2022-02-09 18:21:24.013Z
You need to use
GetEntries
:var sourcePath = '/Library/Application Support/Avid/Audio/Plug-Ins/' var filesInFolder = sf.file.directoryGetEntries({ path: sourcePath }).paths.map(x => x.split('/').slice(-1)) log (filesInFolder)
Chris Shaw @Chris_Shaw2022-02-09 18:24:29.731Z
The above code will give you an array of single entry arrays.
If you want a comma and line return separated list use this:var sourcePath = '/Library/Application Support/Avid/Audio/Plug-Ins/' var filesInFolder = sf.file.directoryGetEntries({ path: sourcePath }).paths .filter(x => x.match('.aaxplugin')).map(x => x.split('/').slice(-1)).join(",\n") log(filesInFolder)
Chris Shaw @Chris_Shaw2022-02-09 18:27:34.469Z
Oops! Forgot to filter for aaxplugin.
Above code corrected.- RRobin Buyer @Robin_Buyer
Works great, thanks Chris! What's the difference between GetFiles and GetEntries?
Chris Shaw @Chris_Shaw2022-02-09 20:07:09.924Z2022-02-09 20:22:10.677Z
I realized that the above script doesn't account for plugins that are in subdirectories in the Plug-ins folder (like UAD, Eventide, etc).
This script is more thorough:
const mainPluginFolder = ["/Library/Application Support/Avid/Audio/Plug-Ins/"]; const subDirectoriesInFolder = sf.file.directoryGetDirectories({ path: mainPluginFolder[0] }).paths.filter(x => !x.match('.aaxplugin')); const allPluginFolders = mainPluginFolder.concat(subDirectoriesInFolder) var allPlugins = []; var tempArray = [] allPluginFolders.forEach( s => { tempArray.push(sf.file.directoryGetDirectories({ path: s }).paths .filter(x => x.match('.aaxplugin')).map(x => x.split('/').slice(-1)[0])); }) tempArray.forEach(i => i.map(x => allPlugins.push(x))) log(`You have ${allPlugins.length} plug-ins installed`) log(allPlugins)
- In reply toRobin_Buyer⬆:
Chris Shaw @Chris_Shaw2022-02-09 20:21:06.607Z
MacOS sits on top of a layer of UNIX. While we see applications and plugins as files, they are actually packages which are a special form of a directory. So when you use
getFiles
it will only return actual files, not directories or packages, That's why you need to usegetEntries
instead. It will return everything in a directory.Chris Shaw @Chris_Shaw2022-02-09 20:33:43.993Z
Oops Again,
Didn't use a recursive search - this should be itsf.ui.proTools.invalidate(); const mainPluginFolder = ["/Library/Application Support/Avid/Audio/Plug-Ins/"]; const subDirectoriesInFolder = sf.file.directoryGetDirectories({ path: mainPluginFolder[0],isRecursive:true }).paths.filter(x => !x.match('.aaxplugin')); const allPluginFolders = mainPluginFolder.concat(subDirectoriesInFolder) var allPlugins = []; var tempArray = [] allPluginFolders.forEach( s => { tempArray.push(sf.file.directoryGetDirectories({ path: s }).paths .filter(x => x.match('.aaxplugin')).map(x => x.split('/').slice(-1)[0])); }); tempArray.forEach(i => i.map(x => allPlugins.push(x))) log(`You have ${allPlugins.length} plug-ins installed`) log(allPlugins)
Chris Shaw @Chris_Shaw2022-02-09 21:04:32.336Z
D'oh!
This is really it this time.
Much simpler:const mainPluginFolder = "/Library/Application Support/Avid/Audio/Plug-Ins/"; const allPlugins = sf.file .directoryGetEntries({ path: mainPluginFolder, isRecursive: true }) .paths.filter((x) => x.endsWith(".aaxplugin")).map((x) => x.split("/").slice(-1)[0]); log(`You have ${allPlugins.length} plug-ins installed`); log(allPlugins)
Chris Shaw @Chris_Shaw2022-02-09 21:15:27.332Z
same thing but removes
.aaxplugin
from the nameconst mainPluginFolder = "/Library/Application Support/Avid/Audio/Plug-Ins/"; const allPlugins = sf.file .directoryGetEntries({ path: mainPluginFolder, isRecursive: true }) .paths.filter((x) => x.endsWith(".aaxplugin")).map((x) => x.split("/").slice(-1)[0].split(".aaxplugin")[0]); log(`You have ${allPlugins.length} plug-ins installed`); log(allPlugins)
- RRobin Buyer @Robin_Buyer
This is super helpful, thanks a bunch!