finder

Is it possible to get programmatic access to finder preview images?

Deadly 提交于 2019-12-11 07:39:36
问题 Finder makes these great preview images of files. Is it possible to access them? Ideally from python. 回答1: Have a look at http://mattgemmell.com/files/source/nsimage_quicklook.zip it does exactly what you want event if it is in obj-c 来源: https://stackoverflow.com/questions/4508457/is-it-possible-to-get-programmatic-access-to-finder-preview-images

Delete multiple files with applescript

断了今生、忘了曾经 提交于 2019-12-11 05:06:07
问题 Let’s say I have multiple files I want to delete, and they’re stored one per line in a files.txt file. I can delete them with set deleteThis to paragraphs of (read "files.txt") repeat with lineFromFile in deleteThis set fileName to POSIX file lineFromFile tell application "Finder" to delete file fileName end repeat This is the logic you usually find online — deleting them one by one, but not only does this screw your “Put Back” option (you have to ⌘ z multiple times), it also plays the trash

Icon for Mac OSX bundle

时光怂恿深爱的人放手 提交于 2019-12-10 12:32:42
问题 I compile a Mac OSX bundle, called MyBundle.bundle, which is used as a plugin for another application. I want the bundle have a unique icon and so I set the Info.plist file to say: <key>CFBundleIconFile</key> <string>MyIcon.icns</string> and place the file MyIcon.icns in the bundle's MyBundle.bundle/Contents/Resources folder. This does not work, the finder show a generic icon for the bundle and ignores the specified MyIcon.icns file. If I change the bundle's extension from .bundle to .app the

How does one relaunch Finder programmatically?

末鹿安然 提交于 2019-12-09 13:09:23
问题 If I OPTION + RIGHT CLICK on the Finder icon, I get a " Relaunch " option in the context menu. I would like to programmatically relaunch Finder, if at all possible. I'm sure there is a better way to do it than to just kill it and let it restart. Assume I have the proper authorization / permissions to do so already. Additionally, I would like to restart Spotlight as well. 回答1: Send it a quit event using AppleScript, then send it an activate event: //tell Finder to quit NSAppleScript

How can i add icon overlay in finder?

ε祈祈猫儿з 提交于 2019-12-09 11:51:15
问题 When we open Dropbox folder, we can see icon on the left bottom of the folder. I am developing an application in which i also want the same behavior. If folder is syncing then it will show sync icon and for other operation it will show other icon. The marked files/folder when viewed in Finder must be shown with a custom icon. But when they are selected for preview ( using spacebar) they must show their original icon ( i.e the blue icon for folder etc) . Can anyone please help me out ?? Thanks

Howto add menu item to Mac OS Finder in Delphi XE2

拈花ヽ惹草 提交于 2019-12-09 02:08:08
问题 I'm working on Delphi XE2 application targetting Mac OS and Windows. And I want to have integration into context menu. For windows this is simple task. But for Mac OS I dont know how to do this. I've read Providing a Service documentation and tried similar code in Delphi but with no luck. Look at simple code for Finder integration trials. App.dpr program App; uses SysUtils, {$IFDEF MACOS} AppKit, CocoaTypes, CoreFoundation, CoreServices, Foundation, Mach, ObjCRuntime, ObjectiveC, OCMarshal,

AppleScript path relative to script location

元气小坏坏 提交于 2019-12-08 13:02:44
问题 I'm trying to launch a Finder window of a folder that's in the same directory as my script. When I run the code below, it launches a blank Finder window set to the path of the script not to the folder. tell application "Finder" tell application "Finder" to make new Finder window set file_path to (path to me) as text set target of Finder window 1 to file_path end tell How can I get the path to the folder of the script, not the script? 回答1: You were close. You do not need the text version of

How do you get the Finder “Kind” for a file?

白昼怎懂夜的黑 提交于 2019-12-08 09:16:11
问题 I want to get the Finder "Kind" for a file. For example, for a file "foo.css", I want the string "CSS style sheet". So far, I'm doing something like this: NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: filename]; NSString *utiType; NSError *error; BOOL success = [fileURL getResourceValue: &utiType forKey: NSURLTypeIdentifierKey error: &error]; if (!success) { NSLog(@"failure during reading utiType: error = %@", error); return; } NSString *utiDescription = (__bridge NSString *)

Add a service in Mac Finder using CLI

人盡茶涼 提交于 2019-12-08 03:26:21
问题 I write a Python script and I want to add it as a service item in Mac Finder. I know I can open Automator window and set it. But I need a command line way. I search the method for a long time and still get nothing... Do anyone know how to achieve this? Thanks a lot. (Using python, apple script or any builtin CLI tool is also acceptable to me) 回答1: To go with my comment here is a very basic example. Which is to show you how services are registered, even the Automator ones. And why I think you

How do you get the Finder “Kind” for a file?

旧城冷巷雨未停 提交于 2019-12-07 03:12:26
I want to get the Finder "Kind" for a file. For example, for a file "foo.css", I want the string "CSS style sheet". So far, I'm doing something like this: NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: filename]; NSString *utiType; NSError *error; BOOL success = [fileURL getResourceValue: &utiType forKey: NSURLTypeIdentifierKey error: &error]; if (!success) { NSLog(@"failure during reading utiType: error = %@", error); return; } NSString *utiDescription = (__bridge NSString *) UTTypeCopyDescription((__bridge CFStringRef) utiType); if (utiDescription) { // use utiDescription here... }