finder

Show folder's contents in finder using Swift

自古美人都是妖i 提交于 2019-12-30 08:14:43
问题 I want to be able to select a folder and show its contents in the Finder. I have managed to select the folder itself and select a file within the folder. But I don't know how to show the contents of an empty folder. e.g. Folder A/Folder B I want to display the contents of folder Folder B (which could be empty). I have written the following code: func showFolder(fileName : String) { var dataPath = homeDirectory.stringByAppendingPathComponent(fileName) var urlPath = NSURL(fileURLWithPath:

Show folder's contents in finder using Swift

一个人想着一个人 提交于 2019-12-30 08:14:27
问题 I want to be able to select a folder and show its contents in the Finder. I have managed to select the folder itself and select a file within the folder. But I don't know how to show the contents of an empty folder. e.g. Folder A/Folder B I want to display the contents of folder Folder B (which could be empty). I have written the following code: func showFolder(fileName : String) { var dataPath = homeDirectory.stringByAppendingPathComponent(fileName) var urlPath = NSURL(fileURLWithPath:

Programmatically add a folder to “Places” in Finder

北城余情 提交于 2019-12-30 00:42:05
问题 I'm trying to figure out how to programatically add a folder to Finder's Places sidebar. I've seen ways to modify it through the Finder Preferences, but I've also seen some applications actually add folders to the sidebar. If someone has any advice/pointers on what I should look up, it would be greatly appreciated (This is for Snow Leopard and Leopard... hopefully it didn't change) 回答1: Try this: -(void) addPathToSharedItem:(NSString *)path { CFURLRef url = (CFURLRef)[NSURL fileURLWithPath

Using NSPredicateEditor, is there a way to get all of the Finder search categories for free?

孤人 提交于 2019-12-25 07:49:08
问题 I'm adding an NSPredicateEditor to my app to allow the user to seach for specific files and categories of files. The default NSPredicateEditor template from Inteface Builder adds a control containing only "name", "address", and "sign" categories. I'm looking for more specific categories. I know that I can add menu items to these menus in Interface Builder, but I would greatly prefer not to maintain a list myself of all of the various categories and values for file searches. In Finder, a great

Play sound with AppleScript using afplay and relative file path

人盡茶涼 提交于 2019-12-24 08:38:49
问题 I'm trying to create an AppleScript that uses afplay (as suggested here) to play a random sound file that's located in a directory within the same directory as the script. folder -- applescript.scpt -- sounds ----- sound-x.aiff I found this comment regarding relative paths to be potentially useful: (POSIX path of (path to me)) However, I keep receiving errors when I try mashing it up with this approach for randomness... set theNumber to 3 set theFiles to {} repeat set file_path to quoted form

Opening files from Finder with a Qt-based application?

烈酒焚心 提交于 2019-12-24 00:45:47
问题 Apparently, for Cocoa applications, you're supposed to implement [[NSApp delegate] application:openFile:] or something like that to allow your application to open files double clicked in Finder. How do you achieve this functionality using Qt, as the name of the file to be opened is not passed on the command line? 回答1: QFileOpenEvent (Qt4/Qt5) should do the trick. Also see https://doc.qt.io/archives/qq/qq18-macfeatures.html 来源: https://stackoverflow.com/questions/3451280/opening-files-from

How do I retrieve all available Finder tags?

给你一囗甜甜゛ 提交于 2019-12-23 18:46:54
问题 I'm trying to retrieve a list of all the available Finder tags. I found NSWorkspace().fileLabels , which does return an array, but only an array of the tag colours, not the tags themselves: print(NSWorkspace.shared().fileLabels) // prints ["None", "Gray", "Green", "Purple", "Blue", "Yellow", "Red", "Orange"] Which as you can see is not even all the default tags, it's missing Home , Work and Important , and obviously doesn't have any of the custom ones that I created. It looks like it's just

Friends-of-friends algorithm written in Python need to be in Fortran 90/95

孤者浪人 提交于 2019-12-23 05:25:54
问题 I'm trying to write my own code for a 'friends-of-friends' algorithm. This algorithm acts on a set of 3d data points and returns the number of 'halos' in the dataset. Each halo is a collection of point whose distance is less than the linking length, b, the only parameter of the program. Algorithmic Description: The FOF algorithm has a single free parameter called the linking length. Any two particles that are separated by a distance less than or equal to the linking length are called "friends

Applescript: Get absolute path of item in a File > Open window

。_饼干妹妹 提交于 2019-12-23 05:09:05
问题 I'm trying to automate JPEGmini which is not entirely scriptable - the only way to control it is via the "Open" dialog. Repeatedly calling it once per image is extremely slow. Instead I'm trying to to perform a search for .jpg or .jpeg files in the "Open" dialog, so that within that result set I can select the batch of files I want to process and open them in a single pass. (More detail after the code example) -- later within the search results list I get, I want to select these set