I’m using the following script to make a series of folders on a share point…
set workFolderSubLlist to "/'Volumes'/'TestShare'/Sub-1/{Sub-1-1,Sub-1-2}"
--
do shell script "/bin/mkdir -p " & workFolderSubLlist
I would like to add the script into the toolbar of the window so when run it would make the folders in the active window, I see that I need to take out the /‘Volumes’/‘TestShare’ bit but I’m not sure what to replace it with?
You need some way to ask the app (which app?) what folder is shown in its active window. If you mean Finder, then you might try something like this:
set dir to missing value
try
tell application "Finder" to set dir to the target of Finder window 1 as alias
end try
if dir is missing value then return
set workFolderSubLlist to quoted form of POSIX path of dir & "Sub-1/{Sub-1-1,Sub-1-2}"
--.
This approach assumes that this script will only be run from Finder. If that assumption does not hold, it will still “work”, but it may be confusing since the script will always ask Finder what folder to use, but the user will likely be looking at something else (the script will use the frontmost Finder window (even a minimized one if they are all minimized), even if Finder itself is not the frontmost app).