Thank you for your effort.
For testing purposes I created a second folder on the same drive “volumes:DA2.0:Inventory2:”.
This contains 1000 folders. Each folder contains the same seven empty subfolders. These folders are name “1 - Description” to “1000 - Description”.
I am using High Sierra 10.13.6 on a Mac Pro (Mid 2010) 2.8GHz Quad-Core Intel Xeon with four internal hard drives and 48GB of RAM.
The “Open folders in tabs instead of windows” preference is enabled and is found under Finder Preferences on this OS.
The tests are being performed while I have other applications running such as PhotoShop, Illustrator, multiple browsers, OpenOffice and some utility apps like Name Changer and PhotoMill.
Compiled as App:
Folder “10 - Description” did not work and created the follow error:
Can’t make «class ocid» id «data optr000000000062170080600000» into type alias. (-1700)
With further testing I found that the above error would occur on any folders named “1 - Description” to “100 - Description”, but there was no error on folders named “101 - Description” to “1000 - Description”.
Folder “549 - Description” took 6 seconds but it opened each folder into a separate window instead of a single tabbed window.
Script Editor:
Folder “10 - Description” did not work.
The term “alias” is highlighted in this line of code
open (theSubFolder as alias)
and creates the following error in the Script Editor.
Script Error
Can’t make «class ocid» id «data optr00000000800C570040600000» into type alias.
With further testing I found that the above error would occur on any folders named “1 - Description” to “100 - Description”, but there was no error on folders named “101 - Description” to “1000 - Description”.
Folder “549 - Description” took 7 seconds but it opened each folder into a separate window instead of a single tabbed window.
use scripting additions
use framework "Foundation"
tell application "Finder"
activate
set theInventoryPath to "volumes:DA2.0:Inventory2:" as alias
set findText to text returned of (display dialog "Enter folder identifier string" default answer "" buttons {"Cancel", "Continue"} default button "Continue")
set theSubFolder to my NSURL_Filename_Contains(my FileSystem_List_Folders(theInventoryPath), findText)
open (theSubFolder as alias)
set {foldersOpenInNewTabs, foldersOpenInNewWindows} to my storeFinderSettings()
set theSubFolder to (theSubFolder as text)
set theSubSubFolders to {"_R", "GS", "K", "O", "T", "WA", "WM"}
repeat with indx from 1 to count of items in theSubSubFolders
open theSubFolder & item indx of theSubSubFolders & ":"
end repeat
my restoreFinderSettings(foldersOpenInNewTabs, foldersOpenInNewWindows)
end tell
on storeFinderSettings()
tell application "Finder"
set foldersOpenInNewTabs to folders open in new tabs of Finder preferences
set foldersOpenInNewWindows to folders open in new windows of Finder preferences
set folders open in new tabs of Finder preferences to true
set folders open in new windows of Finder preferences to false
return {foldersOpenInNewTabs, foldersOpenInNewWindows}
end tell
end storeFinderSettings
on restoreFinderSettings(foldersOpenInNewTabs, foldersOpenInNewWindows)
tell application "Finder"
set folders open in new tabs of Finder preferences to foldersOpenInNewTabs
set folders open in new windows of Finder preferences to foldersOpenInNewWindows
end tell
end restoreFinderSettings
on NSURL_Filename_Contains(NSURLArray, matchString)
set thePredicate to current application's NSPredicate's predicateWithFormat_("lastPathComponent CONTAINS %@", matchString)
return NSURLArray's filteredArrayUsingPredicate:thePredicate
end NSURL_Filename_Contains
on FileSystem_List_Folders(folderObject)
try
theFolders of FileSystem_List_Folders_Files_Packages(folderObject)
on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType --Unhandled errors in the handler are caught here.
error "<FileSystem_List_Folders>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType --Error messages generated in this handler are modified to include the name of the handler.
end try
end FileSystem_List_Folders
on FileSystem_List_Folders_Files_Packages(folderObject)
try
set sourceFolderNSURL to FileSystem_Convert_Object_To_NSURL(folderObject)
set theEntireContents to FileSystem_List_Contents(sourceFolderNSURL)
set directoryKey to current application's NSURLIsDirectoryKey
set packageKey to current application's NSURLIsPackageKey
set theFolders to current application's NSMutableArray's new()
set theFiles to current application's NSMutableArray's new()
set thePackages to current application's NSMutableArray's new()
set booleanTrue to current application's NSNumber's numberWithBool:true
repeat with thisObject in theEntireContents
set {theResult, IsADirectory} to (thisObject's getResourceValue:(reference) forKey:directoryKey |error|:(missing value))
if IsADirectory is booleanTrue then
set {theResult, IsAPackage} to (thisObject's getResourceValue:(reference) forKey:packageKey |error|:(missing value))
if not (IsAPackage is booleanTrue) then
(theFolders's addObject:thisObject)
else
(thePackages's addObject:thisObject)
end if
else
(theFiles's addObject:thisObject)
end if
end repeat
theFiles's removeObjectsInArray:theFolders
return {theEntireContents:theEntireContents, theFolders:theFolders, theFiles:theFiles, thePackages:thePackages}
on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType --Unhandled errors in the handler are caught here.
error "<FileSystem_List_Folders_Files_Packages>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType --Error messages generated in this handler are modified to include the name of the handler.
end try
end FileSystem_List_Folders_Files_Packages
on FileSystem_List_Contents(folderObject)
try
set folderObject to FileSystem_Convert_Object_To_NSURL(folderObject)
set theEntireContents to ((current application's NSFileManager's defaultManager's enumeratorAtURL:folderObject includingPropertiesForKeys:{} options:6 errorHandler:(missing value))'s allObjects())'s mutableCopy()
return theEntireContents
on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
error "<FileSystem_List_Contents>" & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
end try
end FileSystem_List_Contents
on FileSystem_Convert_Object_To_NSURL(fileSystemObject)
try
set fileSystemObject to FileSystem_Convert_Object_To_PosixPath(fileSystemObject)
set fileSystemObject to current application's class "NSURL"'s fileURLWithPath:fileSystemObject
return fileSystemObject
on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
error "<FileSystem_Convert_Object_To_NSURL>" & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
end try
end FileSystem_Convert_Object_To_NSURL
on FileSystem_Convert_Object_To_PosixPath(fileSystemObject)
try
try
set posixPath to POSIX path of fileSystemObject
on error
try
tell application "System Events"
set posixPath to POSIX path of ((path of disk item (fileSystemObject as string)) as alias)
end tell
on error
set posixPath to POSIX path of (fileSystemObject as alias)
end try
end try
return current application's NSString's stringWithString:posixPath
on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
error "<FileSystem_Convert_Object_To_PosixPath>" & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
end try
end FileSystem_Convert_Object_To_PosixPath