Choose a file directory to copy just the folders to a new location.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
use script "FileManagerLib" version "2.3.5"
-- setup the source
set theSourceFolder to choose folder with prompt "Choose a folder to replicate its hierarchy." without invisibles, multiple selections allowed and showing package contents
set theSourceFolder to POSIX path of theSourceFolder as text
set theSourceFolderName to full_name of (get parse object theSourceFolder)
set sourcePathLength to length of theSourceFolder -- used to remove the text from the begining of the original paths
-- get the contents without files and invisibles
set theContents to objects of theSourceFolder result type paths list with searching subfolders and include folders without include invisible items and include files
-- set the destination folder
set theDestinationFolder to choose folder with prompt "Choose a location to place folder heirarchy." without invisibles, multiple selections allowed and showing package contents
set theDestinationFolder to POSIX path of theDestinationFolder as text
-- loop through each path * if folders/files already exist they are ignored
repeat with thePath in theContents
set theNewDestinationPath to theDestinationFolder & theSourceFolderName & "/" & ((current application's NSString's stringWithString:thePath)'s substringFromIndex:sourcePathLength)
set resultText to create folder at theNewDestinationPath
end repeat
Would be much simpler if “copy object” had a option to drop files like “objects of” does.
Also “objects of” with relative paths, ie drop everything left of the parent.
Maybe there is a better way?
Can anyone suggest a way to remove the redundant calls?
ie a folder in a folder only requires one call. this code will make two calls to create them.