finder

NSTableView and drag and drop from Finder

独自空忆成欢 提交于 2019-11-28 19:42:27
I'm trying to implement drag and drop from the Finder into an NSTableView of my app. The setup uses an NSTableView , an array controller which acts as a datasource using Cocoa bindings to a Core Data store. I did the following, basically following various blog posts I found on SO and other sites: In the awakeFromNib of my view controller I call: [[self sourcesTableView] registerForDraggedTypes:[NSArray arrayWithObjects: NSPasteboardTypePNG, nil]]; I subclassed NSArrayController and added the following methods to my subclass (the reasoning for subclassing is that the array controller needs to

Adding a script to MacOS finder contextual menu

旧巷老猫 提交于 2019-11-28 19:23:17
问题 I want to add an option to the finder context menu that calls hg add %1 with %1 being the full path of the selected file in finder. Of course there are more useful cases I can think of, to add to the context menu. Is there a simple way to do that which doesn't involve installing any 3rd party software or coding in a compiled language and building binary plugins? Like creating a script with the script editor and dropping it in /Library/Contextual Menu Items/ ? 回答1: Yeah, I know this is third

Launch OSX Finder window with specific files selected

江枫思渺然 提交于 2019-11-28 16:39:55
I'm trying to programmatically launch an OSX Finder window from an Xcode project. I need the window to open to a specific folder and have specific files within that folder automatically selected. Does anyone know how to do this in either objective c, applescript, or Finder command-line parameters? Thanks! Wevah Objective-C version: NSArray *fileURLs = [NSArray arrayWithObjects:fileURL1, /* ... */ nil]; [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs]; $ open -R <path-to-reveal> Another AppleScript flavor - the Finder's reveal command will both open a window to the

Mac OS X 'compress' option vs command line zip (why do they produce different results?)

孤街浪徒 提交于 2019-11-28 12:06:59
I noticed that the command line 'zip' tool and Mac OS X's 'Compress XXX' option (available via right click in finder) are giving different output files. Not only is the size of the file a few hundred bytes bigger but the content is significantly different as well. How can I find out what command the Finder is using for compression? Take a look at An AppleScript to compress a Finder selection article. try tell application "Finder" set theSelection to the selection set selectionCount to count of theSelection if selectionCount is greater than 1 then error "Please select only one Finder item

Add Item to Finder Sidebar

流过昼夜 提交于 2019-11-28 11:26:44
I would like to add a new item to the Finder sidebar. I found out that the Finder keeps the list of "places" in `~/Library/Preferences/com.apple.sidebarlists.plist. I was able to read the file using Carbon API and saw that each item had Name, icon and alias. Using a 3rd party application such as PlistEdit Pro I was able to update the alias. My question is how to update the alias using Carbon API. Was not able to find a way to create alias that will open in Finder. It seem that both Dropbox and PlistEditor Pro was able to find the way. Asmus Take a look here : The Shared File List API is new to

move a file in finder with applescript

元气小坏坏 提交于 2019-11-28 08:47:34
问题 I just want to move an image from one folder to the other, replacing the one that's already in there: tell application "Finder" copy file "/Users/xx/Documents/img.jpg" to folder "/Users/xx/Documents/State" end tell When I run it, I get an error message saying Finder got an error: Can’t set folder [path] to file [path]"."number -10006 from folder [path] Please help me! 回答1: Try: tell application "Finder" duplicate POSIX file "/Users/xx/Documents/img.jpg" to POSIX file "/Users/xx/Documents

Swift 3: Set Finder label color

醉酒当歌 提交于 2019-11-28 07:51:31
I'm trying to set the colored labels shown by the finder. The only function I know is setResourceValue. But this needs localized names! I could image my mother language and english as well, but all others I don't know. I can't believe, that this should be the way. Is the are translation function, which takes a standard parameter like an enum or int and delivers the localized color name? I have an running part, but only for two languages (German and English): let colorNamesEN = [ "None", "Gray", "Green", "Purple", "Blue", "Yellow", "Red", "Orange" ] let colorNamesDE = [ "", "Grau", "Grün",

How do you programmatically put folder icons on the Finder sidebar, given that you have to use a custom icon for the folder?

我的梦境 提交于 2019-11-28 07:05:55
Am currently working on a project, and though I can add sidebar items by adding to the com.apple.sidebarlists.plist file then restarting Finder, I can't seem to know how to make the folder icons show up using its assigned custom icon. Can anyone point me to a link or a solution that would make me do this? Thanks a bunch in advance! There's no supported way to do this using pure Cocoa. Use the LSSharedFileList API, instead. It's the supported way to manage the sidebar lists, and you can provide a custom icon (as an IconRef from Icon Services) when you insert an item. I don't know about the

Tagging files with colors in OS X Finder from shell scripts

﹥>﹥吖頭↗ 提交于 2019-11-28 06:05:45
One can tag files and folders with a color in the Mac OS X Finder. Is there a way to do this from a shell script? This shell script takes the file or folder name as its first argument and the label index (0 for no label, 1 for red, ..., 7 for gray) as its second argument. #!/bin/sh osascript -e "tell application \"Finder\" to set label index of alias POSIX file \"`cd -P -- "$(dirname -- "$1")" && printf '%s\n' "$(pwd -P)/$(basename -- "$1")"`\" to $2" More directly, if $filename is a shell variable with the absolute path name of the file or folder to be labeled and $label is a shell variable

Open terminal here in Mac OS finder [closed]

寵の児 提交于 2019-11-28 02:30:25
Is there something similar to the "Open Command Window Here" Windows Powertoy for Mac OS? I've found a couple plugins through a google search but wanted to see what works best for developers out there. Chris Page As of Mac OS X Lion 10.7, Terminal includes exactly this functionality as a Service. As with most Services, these are disabled by default, so you'll need to enable this to make it appear in the Services menu. System Preferences > Keyboard > Shortcuts > Services Enable New Terminal at Folder . There's also New Terminal Tab at Folder , which will create a tab in the frontmost Terminal