Context, if the folder specified contains subfolders then set the current view to icon view. Else, set the current view to flow view (aka gallery view). I provided a simple example of what I’m looking for. The current example returns: error "Can’t make «class cfol» Number: -1700. This question is pretty straightforward yet I have found no relatively straightforward answer. Any help is much appreciated!
tell application “Finder”
if contents of the folder “Downloads” of home contains folders then
set the current view of the window of folder “Downloads” of home to icon view
else
set the current view of the window of folder “Downloads” of home to flow view
tell application "Finder"
set currentWindow to the front Finder window
set currentDirectory to the target of currentWindow
try
set aFolder to the first folder of currentDirectory
set the current view of currentWindow to icon view
on error
set the current view of currentWindow to flow view
end try
end tell
Please use the applescript code tags when posting code.
Or this is the same but may be a bit clearer to read:
tell application "Finder"
set currentWindow to the front Finder window
set currentDirectory to the target of currentWindow
if exists (the first folder of currentDirectory) then
set the current view of currentWindow to icon view
else
set the current view of currentWindow to flow view
end if
end tell