I’ve created this short script which opens the finder to a desired directory location. The script is not elegant but work.
tell application "Finder"
open "Data" -- display DATA directory/folder information
tell the front window to set toolbar visible to false
open (path to home folder as text) & "recVIDEO" --display /users/recVIDEO subfolder information
tell the front window to set toolbar visible to false
end tell
In the meantime there is another directory I want to open but do not know how to get there.
For example, if I click on the listed Device (on the sidebar) there is a device with my name “Daniel Paquin” If I click on it, the dialog box showing the following folders appears:
Would someone knows how to automatically point to that place ?
Lastly, at the top it shows the Name, Size, Date Created, Date modified. Let’s say I only want to see the name nothing else for each file being displayed. Can that be done?
(*
http://www.macscripter.net/post.php?tid=45838
*)
set thePaths to {}
set end of thePaths to "DATA" # On my machine, 1139 folders are named Data. I guess that a more precise path would be welcome.
set end of thePaths to (path to home folder as text) & "recVIDEO" --to display /users/recVIDEO subfolder information
set end of thePaths to "SSD 500" # an external HD
set end of thePaths to "Yosemite Install Disk - 10.10.4" # an USB card
repeat with aPath in thePaths
my openThisFolder(aPath)
end repeat
on openThisFolder(hfsPath)
tell application "Finder"
try
open folder hfsPath
tell the front window to set toolbar visible to false
end try
end tell
end openThisFolder
This “place” doesn’t really exists.
It’s just a way to display the connected devices in a single window.
Here in France it’s named “iMac de ???” but I disable this feature in the Finder preferences.
I assume that it may be clicked with GUI Scripting but I’m too tired to try that this evening.
As far as I know we can’t hide columns by script.
We may do it by hand.
Control click the title of a column reveal a popup menu in which we must uncheck the items which must be hidden.
I assume that it may be done with GUI Scripting but I’m too tired to try this evening.
Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) vendredi 14 juillet 2017 21:50:28
I am trying to automate this process (opening file browsers) because I have users who will be working with me and never used MAC before. For sure it sound simple, however they have many other important task to do that I do not want them to get stuck on that. There are people who become very nervous just thinking they will have to work with MACs. They can get out of focus. This is why I am trying to minimise some of their stress.
You are right on Yvan, it’s the place where it’s name … This is unfortunate, for my purpose it’s a nice window which provides some root directories other than the one found under Macintosh HD.
I retrieved a piece of code poset on AppleScriptUserList by Shane STANLEY which will give you a neat way to get the list of devices available in the “iMac de ???” window.
# Three instructions required by the handler which use ASObjC
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
set mountedDevices to my getMountedDevices()
tell application "Finder"
repeat with aDevice in mountedDevices
try
open folder aDevice
end try
end repeat
end tell
on getMountedDevices()
# this code was posted by Shane STANLEY on 2017/06/20 in the thread "Unmounted Disks" of applescript-users@lists.apple.com
set theResult to do shell script "diskutil list -plist"
-- make dictionary from property list
set theResult to current application's NSString's stringWithString:theResult
set pListDict to theResult's propertyList()
-- extract relevant info
set disksAndParitions to pListDict's objectForKey:"AllDisksAndPartitions"
set partitionsArray to current application's NSMutableArray's array() -- to store values
repeat with anEntry in disksAndParitions
set thePartitions to (anEntry's objectForKey:"Partitions")
if thePartitions = missing value then -- no partitions means a volume
(partitionsArray's addObject:anEntry)
else
(partitionsArray's addObjectsFromArray:thePartitions)
end if
end repeat
-- filter by Content type
set thePred to current application's NSPredicate's predicateWithFormat:"Content == 'Apple_HFS'"
set partitionsArray to partitionsArray's filteredArrayUsingPredicate:thePred
-- get names
return (partitionsArray's valueForKey:"VolumeName") as list
end getMountedDevices
Of course this code will no longer work when you will switch from Hfs to APFS.
Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) dimanche 16 juillet 2017 11:13:43
Here is a bit of GUIScripting disabling every columns minus Name one in list mode.
(*
http://www.macscripter.net/post.php?tid=45838
*)
set the_App to application id ("com.apple.finder")
set path2app to path to the_App as text
set preferences_loc to localized string "AX24" from table "Localizable" in bundle (path2app as «class furl»)
set desktop_loc to localized string "AX70" from table "Localizable" in bundle (path2app as «class furl»)
tell application "Finder" to activate
tell application "System Events" to tell process "Finder"
set frontmost to true
repeat
# Close every floating window
if exists (window 1 whose subrole is "AXSystemFloatingWindow") then
click (first button of (window 1 whose subrole is "AXSystemFloatingWindow") whose subrole is "AXCloseButton")
else
exit repeat
end if
end repeat
repeat
# Close every preferences window
if exists (window 1 whose description is preferences_loc) then
click (first button of (window 1 whose description is preferences_loc) whose subrole is "AXCloseButton")
else
exit repeat
end if
end repeat
end tell
tell application "Finder" to tell Finder window 1
select it # In case there is no selected Finder window which would open options window for Desktop
# Force Finder to use List View
if current view is not list view then set current view to list view
end tell
tell application "System Events" to tell process "Finder"
set frontmost to true
-- properties of windows
if not (exists (first window whose subrole is "AXSystemfloatingwindow")) then
# The floating window isn't open, try to open it
keystroke "j" using {command down}
end if
repeat 10 times
delay 0.1
try
exists (first window whose subrole is "AXSystemfloatingwindow")
exit repeat
end try
end repeat
# The floating window is open
tell (first window whose subrole is "AXSystemfloatingwindow")
-- class of UI elements --> {checkbox, checkbox, static text, pop up button, pop up button, static text, group, button, button, static text}
if its title = desktop_loc then error "Doesn't apply to Desktop !"
tell group 1
-- class of UI elements --> {static text, button, button, radio group, static text, pop up button, static text, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox}
set checkBoxCount to count checkbox
if checkBoxCount > 3 then
# Disable the columns
repeat with i from 1 to (checkBoxCount - 3)
if value of checkbox i = 1 then click checkbox i --"Date de modification"
end repeat
else
error "requires Column mode !"
end if
end tell # group 1
end tell
end tell
Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) dimanche 16 juillet 2017 19:10:20