Everytime I create a new session, I always create 1 folder inside the main session folder called "Others".
Inside "Others" I then create "Misc" and "Old Cuts". I was wondering if there's a way to automate all of that.
- Christian Scheuer @chrscheuer2019-06-27 15:35:15.692Z
Yes @dario.ramaglia there is :)
Here's an example of creating this folder structure of the currently open session in PT:
//Get the directory (folder) of the currently open PT session var sessionDir = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/'); //Create a sub-directory under the session folder, called "Others" sf.file.directoryCreate({ path: sessionDir + '/Others' }); //Create a sub-directory under the session folder's sub-directory "Others", called "Misc" sf.file.directoryCreate({ path: sessionDir + '/Others/Misc' }); //Create a sub-directory under the session folder's sub-directory "Others", called "Old Cuts" sf.file.directoryCreate({ path: sessionDir + '/Others/Old Cuts' }); //Open the "Others" sub-directory sf.appleScript.finder.open(sessionDir + '/Others'); sf.ui.finder.appActivate(); sf.ui.finder.windows.first.elementRaise();
Dario Ramaglia @dario.ramaglia
I need a new little help :)
What if I want SF to ask me how to name a folder?
Let's say I want to create all the hierarchy of folders for my new project, I'd like SF to ask me for the name of the project so it cane rename the main folder accordingly.
What do you think? A good idea?Christian Scheuer @chrscheuer2020-02-24 18:05:32.075Z
Use
prompt
and save the output into a variable, for example like this:var sessionName = prompt('What should we call your new session?'); sf.file.directoryCreate({ path: '~/Documents/My Pro Tools Sessions/' + sessionName + '' });
Christian Scheuer @chrscheuer2020-02-24 18:38:48.171Z
Note for putting in variables inside strings like paths, you might want to use back-tick string syntax (string interpolation) instead, as it makes things a little clearer:
var sessionName = prompt('What should we call your new session?'); sf.file.directoryCreate({ path: `~/Documents/My Pro Tools Sessions/${sessionName}` });
Dario Ramaglia @dario.ramaglia
Last question, I swear.
Is it possible to create folder in the focused Finder window instead of a pre-defined folder?Dario Ramaglia @dario.ramaglia
This could be a solution.
I Just drug the folder on the second prompt ;)var sessionName = prompt('What should I call your main project folder?'); var pathName = prompt('Where should I put it?') sf.file.directoryCreate({ path: `${pathName}/${sessionName}` }); sf.file.directoryCreate({ path: `${pathName}/${sessionName}` + '/Folder1' }); sf.file.directoryCreate({ path: `${pathName}/${sessionName}` + '/Folder2' }); sf.file.directoryCreate({ path: `${pathName}/${sessionName}` + '/Folder1/SubFolder1' }); //Open the "Others" sub-directory sf.appleScript.finder.open(`${pathName}/${sessionName}`); sf.ui.finder.appActivate(); sf.ui.finder.windows.first.elementRaise();
- In reply todario.ramaglia⬆:
Christian Scheuer @chrscheuer2020-02-28 04:12:45.591Z
You can get info about the open Finder window in a number of ways:
//To get the path to the first selected file: var path = sf.ui.finder.firstSelectedPath; //To get the path to the open folder in the top most window: var dirPath = sf.appleScript.finder.firstWindow.targetPath;
Christian Scheuer @chrscheuer2020-02-28 04:13:42.213Z
This means in your case I'd probably do:
var sessionName = prompt('What should I call your main project folder?'); var pathName = sf.appleScript.finder.firstWindow.targetPath; sf.file.directoryCreate({ path: `${pathName}/${sessionName}` }); sf.file.directoryCreate({ path: `${pathName}/${sessionName}` + '/Folder1' }); sf.file.directoryCreate({ path: `${pathName}/${sessionName}` + '/Folder2' }); sf.file.directoryCreate({ path: `${pathName}/${sessionName}` + '/Folder1/SubFolder1' }); //Open the "Others" sub-directory sf.appleScript.finder.open(`${pathName}/${sessionName}`); sf.ui.finder.appActivate(); sf.ui.finder.windows.first.elementRaise();
- In reply todario.ramaglia⬆:Chip Sloan @ChipSloan
I've got a version of this working and am wondering it I can add a line of code to always create folders inside the session folder when a new session is created. I always create the same 3 subfolders in my sessions, Downloads, Mixes and Other. I would love to have those just auto create in every session and not have to devote a command or button to it.