user635064
user635064

Reputation: 6247

Convert NSURL to AppleScript file path

I am using NSAppleScript to run applescript from within my application. My problem is that I have an NSURL that I want converted to string. When I convert it, I get: path/to/my/file, but applescript requires path:to:my:file. How can I convert my NSURL into this format? THanks.

Upvotes: 2

Views: 1413

Answers (2)

markhunte
markhunte

Reputation: 6932

You might find this useful it will convert the pathString to a HFS style path (with colons):

NSString* pathString = [@"~/Desktop/Home.m4v" stringByExpandingTildeInPath];
NSURL* theFileURL = [NSURL fileURLWithPath:pathString];

NSString* path = [(NSString*)CFURLCopyFileSystemPath((CFURLRef)theFileURL, kCFURLHFSPathStyle) autorelease];

NSLog(@"path= %@",path);

Upvotes: 4

Wevah
Wevah

Reputation: 28242

instead of

file "foo:bar:baz"

use

POSIX file "foo/bar/baz"

Upvotes: 3

Related Questions