How do I get a file reference to a non-existant file?

Basically, I want a way to hard code a “choose file name”. For the life of me though, I can’t figure out how to get a reference to a non-existant file.

How exactly are you supposed to specify output file names for various scriptable applications? All I want is to save a quicktime file–though, I can’t find anything other than “choose file name” that the “export to” for quicktime will allow.

Something like this (QT code untested).

set outputPath to "Mac HD:some folder:nuther folder:file name"

tell application "QuickTime Player"
export to file outputPath
end tell

Unfortunately, this doesn’t work unless the file at outputPath already exists. Seems like this should be an easy task, but I can’t manage to find any info or examples of how.

I’m also unable to get export to work and it was working not too long ago. Maybe it was the upgrade to QT 6.3 that broke something. FYI, I’m running OS X 10.2.6, QT 6.3 (not QT Pro). I wonder if Apple has finally cut off Pro features that have been available via AppleScript even when Pro wasn’t purchased. Do you have QT Pro?

What you want to do is create a file specification first to a file that doesn’t exist. Say I wanted a file spec to a file on the dektop. Something like this:

set desk_path to (path to desktop) as string
set file_spec to (deskPpath & “New Movie”) as file specification

Then, in QuickTime export to file_spec


Thanks Kel,

Unfortunately, that doesn’t work either. I just looked up the error: notAllowedToSaveMovieErr (-2126)

I’m guessing that this is a result of not having QT Pro because the movie can in fact be exported (QT Player provides a way to check). :?

I have QuickTime Pro so I’m not sure if it’s the same in QuickTime but for me, the “export” command requires a reference and a class for the exported file. Thus, the following script works for me saving to a non-exisitent file:


Thanks very much; this does the trick. (With QT Pro anyways)

Though, I’ve already hit the next problem. :frowning: I can’t get a reference to a unicode filename. Eg, consider a unicode file passed as in a droplet–this can’t find the file…

set f to dropped_file as string
set g to file f

Oh well.

Hi Rob,

I’m not using QuickTime pro. I’,m using QT 6.3 and OS 10.2.6 also. The following worked for me:

set desk_path to (path to desktop) as string
set file_spec to (desk_path & “New File”) as file specification
set file_ref to (choose file of type “AIFF”)
tell application “QuickTime Player”
open file_ref
tell front movie
end tell
export front movie to file_spec as MPEG4
end tell

I hadn’t tried AIFF to MPEG4 yet and it sounds pretty good. Went from 21MB to 2 MB. I always get caught after not scripting QuickTime for a long time on the export type. Note that MPEG4 is not in quotes. Can’t think of anything else that could cause your error. I forget what type of error you had while writing this post so I might write back.


Hi wintermute,

In a droplet, the parameter is a list. So like if you have a droplet like this:

on open file_list
– your stuff here
end open

the variable file_list is a list even if you drop one file on the droplet. To get the item of the list do something like this:

set first_file to item 1 of file_list

first_file is now a reference to the file dropped on the droplet. Usually you don’t know how many file are dropped on or even if folders are included. Then, you would use a repeat loop:

repeat with this_item in file_list
– if this_item is a folder then do whatever
– else it’s a file so do whatever
end repeat

There’s other error checking stuff so experiment. I’m not sure if this is the cause of your problem but hope you find it.


This works fine, although the choose file dialog didn’t recgnize the . AIFF file that was just copied from a CD. It even has the aiff extension. Weird.

I still can’t get it to export a regular movie “as QuickTime Movie”. I’ll download some fresh movie files and try again when I have time. :slight_smile:

Thanks Kel!

– Rob

Follow-up: I just happened to have the opportunity to download a very cool movie [1] and I was able to export it as QT movie just fine. I must have been using some bad movie files to test with earlier. :?

[1] The movie, available for download from this MacUpdate page, shows how “Unstoppable Progress” works. Unstoppable Progress is a neat hack created for a contest at this years MacHack conference. Very cool! Watch the movie! 8)

Hi Rob,

That is a cool movie! I don’t think I’ll try the hack though. Glad your computer is working fine.

Have a good day,

I’m late to this thread, but…

I’ve found when having difficulty such as wintermute and Rob mentioned in setting a ‘non-existent’ file reference, opening the file for access, then closing it again pretty much guarantees that the subject app can find it.

set the_file to ((the desktop) as text) & “File”
open for access file the_file
close access file the_file

Rob may remember a bug in GraphicConverter that produced a similar problem. This provided a workaround.

Peter B.

Yup, I remember it well. I fought that bug for quite some time. :evil: