Applescript move files

I have this applescript that when i place files in a folder on my desktop it will prompt me for a subject and email it to my gmail account. I wanted to add a line that would kick those file(s) back out to my desktop apon completion. It sends the files but will not proceed... if i run it in the script editor it does kick them out... why arent both of my commands running?
[ code ]
on adding folder items to thefolder after receiving theAddedItems
repeat with eachitem in theAddedItems
set theSender to "Me<[email protected]>"
set recipCommon to "Files"
set recipAddress to "[email protected]"
set msgText to "Some text"
tell application "Mail"
set newmessage to make new outgoing message with properties {content:msgText & return}
tell newmessage
set sender to theSender
display dialog "Please Enter a Subject:" default answer ""
set theSubject to text returned of result
set subject to theSubject
make new to recipient with properties {name:recipCommon, address:recipAddress}
make new attachment with properties {file name:eachitem} at after the last paragraph
end tell
send newmessage
end tell
end repeat
end adding folder items to
try
tell application "Finder"
move every file of folder "Macintosh HD:Users:home:Desktop:somefolder:" to folder "Macintosh HD:Users:home:Desktop:"
end tell
end try

You can't run a folder action script in an open Script Editor window without substituting variables.
A better solution would be to not even use a folder action to begin with, since you want the file to remain on your desktop anyway. This variation makes you select one or several files from a dialog while leaving the files intact:
set theItems to choose file with multiple selections allowed
repeat with eachItem in theItems
set theSender to "Me<[email protected]>"
set recipCommon to "Files"
set recipAddress to "[email protected]"
set msgText to "Some text"
tell application "Mail"
set newmessage to make new outgoing message with properties {content:msgText & return}
tell newmessage
set sender to theSender
tell application "Finder" to display dialog "Please Enter a Subject:" default answer (name of eachItem as string)
set theSubject to text returned of result
set subject to theSubject
make new to recipient with properties {name:recipCommon, address:recipAddress}
make new attachment with properties {file name:eachItem} at after the last paragraph
end tell
send newmessage
end tell
end repeat
Another possibility might be to make a "droplet", where you drop the file(s) on the script to send them.
But the most elegant Mac-like solution is to use the Applescript menu.
Enable the Applescript menu and you will have a fast convenient way to access any script for any application. There are some super cool tricks with Script Menu.
To enable the Applescript Menu, open the application at
/Applications/AppleScript/AppleScript\ Utility.app
and select "Show Script Menu". The frontmost application (in focus) has its own script menu so it is always changing. You can create a folder for the frontmost application by clicking the menu icon, then selecting "Open Scripts Folder", then "Open ** Scripts Folder". A new empty window will appear ready for you to populate with Applescripts. That is too cool!
Put your script in that folder and now whenever Mail.app is in front you have fast access to the script.
But alas, selecting files from a dialog is not convenient enough for us Mac folk, so here is the easiest way of all.
Replace the first line of the script with this one:
tell application "Finder" to set theItems to the selection
Now all you have to do is select (highlight) the files in any window and bring Mail.app to the front and click the Applescript icon. That is too easy!

Similar Messages

  • Having an AppleScript Move All Files of a Certain Type From Sub-Folders to Trash

    Greetings, everyone. With my introductory post, I would like to ask for help with an AppleScript I've been slaving over for the past five hours or so. I have tried Terminal and Finder commands both, along with lots and lots of Googling, and I cannot seem to get this to work.
    Specfically, I want a script to look into a folder and all of its sub-directories, locate all files with a certain extension (in this case, APP), and then send every one of those files to the trash. Originally, I planned to delete them directly with Terminal commands that required verification, but I couldn't get that to work, and I thought that this would be a more average user-friendly version, anyway.
    I also wondered if there was any universal means of referring to a system drive without referring to it by its name, since (as you'll see in the script) the directory that these *.app files will be moved from is in the Users/Shared hierarchy. However, it's meant to be used on multiple computers, so naming the OS drive on one won't work for others. If no such wild card exists, is what I'm doing now (having the script placed in the root folder of the OS drive) acceptable?
    As it is, when I run this script, it displays all the dialogs, but the APP files aren't moved. It doesn't error at all in the AppleScript editor, it just runs and then closes down. I don't know what I'm doing wrong.
    Thank you in advance for any help you can provide.
    =====
    if button returned of (display dialog "Trash all of the APP files in your SuchAndSuch folder? (This script must be in the root directory of your system drive.)" buttons {"Yes, I'm ready", "No"} default button 2 cancel button 2 with title "SuchAndSuch Folder Prep" with icon caution) is "Yes, I'm ready" then
        set theFolder to ":Users:Shared:SuchAndSuch:" as alias
        tell application "Finder"
            set theFiles to every file of theFolder whose name extension is "app"
            move theFiles to trash
        end tell
    end if
    if button returned of (display dialog "The APP files have been trashed." buttons {"OK"} default button 1 with title "SuchAndSuch Folder Prep" with icon 1) is "OK" then
    end if

    Well, you've done more fiddling than that; you've moved everything inside the Finder tell block.  Why did you do that?  If you recall my point 2 above, it is difficult to use POSIX paths or the POSIX file command inside Finder tell blocks without generating errors, but you've done both in your revision.  I'm surprised that you're surprised that it doesn't work. 
    Applescript tries to be user-friendly, but it's still a programming language, and like any programming language the devil is in the details.  Changes that seem small and innocuous to you can make big differences in the result you get.
    Now:
    /Users/Shared should be machine independent in POSIX: you don't need to specify the hard drive name and it should be universal on all OS X installations.  You can specify it directly.
    The Finder's delete command moves fils to the trash, it doesn't erase them.  Trying to use the move command to get files to the trash is a little bass-ackwards.
    Don't put anything inside a Finder tell block unless it has to be processed by the Finder.  If you do you're just begging for errors.
    There's no need to put the script at the root level of the drive.  If the Finder needs permission to delete a file it will ask.
    untangled and revised:
    set subfolderOfSharedFolder to quoted form of "/Users/Shared/<subfolder name>"
    set response to display dialog "Trash all of the APP files in your <subfolder name> folder?" buttons {"Yes, I'm ready", "No"} default button 2 cancel button 2 with title "<subfolder name> Folder Prep" with icon caution
    if button returned of response is "Yes, I'm ready" then
      -- run spotlight search
              set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.app c' -onlyin " & subfolderOfSharedFolder)
      -- convert posix paths to file specifiers
              repeat with thisFile in filesToDelete
                        set (contents of thisFile) to POSIX file thisFile
              end repeat
              tell application "Finder"
      delete filesToDelete
              end tell
              if button returned of (display dialog "The APP files have been trashed." buttons {"OK"} default button 1 with title "SuchAndSuch Folder Prep" with icon 1) is "OK" then
              end if
    end if

  • Using Automator and Applescript to search and move files to flash drive

    I've used applescript and automator to do simple tasks like watch folders and move files and rename files, but that is about the extent. I am wondering if it is possible to set up a automator service or app that will do several things.
    When a flash drive is plugged it, it will ask for a file to be searched for, then it will search a predetermined directory for files with the word or number in them and then it will copy the found files to the mounted flash drive.
    Any help would be greatly appriciated!
    Thanks!

    As a start, you can use launchd to run a script when a volume is mounted:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
              <key>Label</key>
              <string>com.tonyt.LaunchOnVolMount</string>
              <key>ProgramArguments</key>
              <array>
                        <string>LaunchOnVolMount.sh</string>
              </array>
              <key>QueueDirectories</key>
              <array/>
              <key>StartOnMount</key>
              <true/>
              <key>WatchPaths</key>
              <array/>
    </dict>
    </plist>
    You can then have the LaunchOnVolMount.sh script perform the tasks you need.
    You can incorporate Applescript within the Bash script with osascript:
    #!/bin/bash
    answer=$( osascript -e 'tell app "System Events" to display dialog "What file do you want to search for?" default answer "" ' )
    echo $answer
    I beleive that you can also call an Applescript from launchd

  • Applescript to move files in a folder to the parent folder.

    I've got tens of thousands of files in folders that I'd like to be automatically moved out of the folder thier in to the parent folder.
    For example:
    Summer Vacation/img/photo.jpg
    I need all of the files in the folder img to be moved out of img and into Summer Vacation.
    Monthy Report/final/report.ppt
    I need all of the files in the folder final to be moved out of final and into Monthly Report.
    So the specifics are many and varying. A script that would work without specific file and fodler names might work better.
    Any thought on this would be greatly appreciated.

    You can use launchd to run a script daily.
    The script would move files that are older than 7 days (based on the access time) from the Downloads Folder to the Desktop (edit as needed):
    #!/bin/bash
    seven_days_ago=$(date -v -168H +%s)
    for f in ~/Downloads/*
    do
              if [ -e "$f" ] ; then
                        if [ $(stat -f %Da "$f") -lt $seven_days_ago ]; then
                                  mv "$f" ~/Desktop
                        fi
              fi
    done
    Put this script in your favorite Folder (I use ~/Library/Scripts)
    Now to trigger the script daily, place this launchd plist in ~/Library/LaunchAgents/, and edit for the location of the script, and when you want it to run (I have it at 8:24pm daily).  Reboot (or log out and back in) for the launchd to take effect.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
              <key>KeepAlive</key>
              <false/>
              <key>Label</key>
              <string>com.tonyt.MoveFiles</string>
              <key>ProgramArguments</key>
              <array>
                        <string>/Users/Tony/Library/Scripts/MoveFiles.sh</string>
              </array>
              <key>StartCalendarInterval</key>
              <dict>
                        <key>Hour</key>
                        <integer>20</integer>
                        <key>Minute</key>
                        <integer>24</integer>
              </dict>
    </dict>
    </plist>

  • Export MOV files to MP3

    Dear all,
    I need to convert a movie file (MOV format) to an audio-only file (MP3 format). I've followed the tutorial on:
    http://www.mango-design.net/2009/03/mac-converting-mov-files-to-mp3/
    I believed it was very simple as explained in the document but instead I have 2 problems:
    1) I haven't the 'Script Editor/Make New AppleScript' function under the 'services' menu (point 3 in the document). Can anyone tell me how can I add that menu?
    2) Anyway, when I run the script directly with AppleScript Editor (point 1 in the document) I receive the following error:
    "Expected end of line but found number."
    I tried to solve the problem (I supposed It was simple, really not) in different ways without success.
    I run on 10.6.2.
    Could anyone help me?
    Thank you in advance,
    --Carlo
    AppleScript:
    set saveRef to (choose file name with prompt "Save audio track as AIFF" default name "untitled.aiff")
    tell application "QuickTime Player"
    export movie 1 to saveRef as AIFF
    ----------

    Hi Oriolo,
    You must [install QuickTime Player 7|http://support.apple.com/kb/HT3678?viewlocale=en_US] and use it to run your script, as follows:
    *set saveRef to (choose file name with prompt "Save audio track as AIFF" default name "untitled.aiff")*
    *tell application "QuickTime Player 7"*
    *export document 1 to saveRef as AIFF*
    *end tell*

  • Move files and create unique name something wrong with my script

    Can you see where I might be going wrong here?
    Just trying to create a unique name if something exists.
    In English.
    Move file to the destinationFolder
    Item exists in destinationFolder > Move file in the destination folder to the fake Trash > If it exists in fakeTrash too then give it a new name an ending of_a.psd then out it in the trash
    Once thats done move start file to the destination folder.
    Currently when the file exists in the destination folder and in the trash, I get the prompt then the error
    error "System Events got an error: Can’t get disk item \"NN_FR10WW06290PK3LE.psd\"." number -1728 from disk item "NN_FR10WW06290PK3LE.psd"
    set fileMatrix to {¬
              {folderName:"BHS", prefixes:{"BH", "SM", "AL"}}, ¬
              {folderName:"Bu", prefixes:{"BU"}}, ¬
              {folderName:"Da", prefixes:{"ES"}}, ¬
              {folderName:"Di", prefixes:{"DV"}}, ¬
              {folderName:"Do", prefixes:{"DJ", "RA"}}, ¬
              {folderName:"In", prefixes:{"GT", "CC"}}, ¬
              {folderName:"Fr", prefixes:{"FR"}}, ¬
              {folderName:"No", prefixes:{"NN"}}, ¬
              {folderName:"Ma", prefixes:{"MA", "MF", "FI", "MC", "MH", "MB"}}, ¬
              {folderName:"Pr", prefixes:{"PR"}}, ¬
              {folderName:"To", prefixes:{"TM15", "TM11", "TM17"}}, ¬
              {folderName:"Wa", prefixes:{"WA"}}, ¬
              {folderName:"Se", prefixes:{"SE"}}}
    tell application "Finder"
              set theHotFolder to folder "Hal 9000:Users:matthew:Pictures:HotFolderDone"
              set foldericon to folder "Hal 9000:Users:matthew:Pictures:Icons:Rejected Folder Done"
              set fakeTrash to folder "Hal 9000:Users:matthew:FakeTrash"
      ---here
              repeat with matrixItem in fileMatrix -- look for folder
                        set destinationFolder to (folders of desktop whose name starts with folderName of matrixItem)
                        if destinationFolder is not {} then -- found one
                                  set destinationFolder to first item of destinationFolder -- only one destination
                                  set theFolderName to name of destinationFolder
                                  repeat with aPrefix in prefixes of matrixItem -- look for files
                                            set theFiles to (files of theHotFolder whose namestarts with aPrefix) as alias list
                                            if theFiles is not {} then repeat with startFile intheFiles -- move files
                                                      try
      move startFile to destinationFolder
                                                      on error
      activate
                                                                display dialog "File “" & (name ofstartFile) & "” already exists in folder “" & theFolderName & "”. Do you want to replace it?"buttons {"Don't replace", "Replace"} default button 2 with icon 1
                                                                if button returned of result is "Stop"then
                                                                          if (count theLastFolder) is 0 thendelete theLastFolder
                                                                          return
                                                                else if button returned of result is"Replace" then
                                                                          set fileName to get name ofstartFile
                                                                          if exists file fileName indestinationFolder then ¬
                                                                                    try
      --next line moves existing file to the faketrash
      move file fileName of destinationFolder to fakeTrash
      move file startFile to destinationFolder
      --if it already exists in fake trash give it a new name then move that file to fake trash
                                                                                    on error errmess numbererrnum -- oops (should probably check for a specific error number)
                                                                                               log "Error " & errnum& " moving file: " &errmess
                                                                                               set newName to mygetUniqueName(fileName,fakeTrash)
                                                                                               set name of fileNameto "this is a unique name"-- or whatever
                                                                                               set name of fileNameto newName
      --Now move the renamed file to the fake trash
      move file fileName to fakeTrash
      --now move the startfile to destination folder
      move file startFile to destinationFolder
                                                                                    end try
                                                                else -- "Don't replace"
                                                                          if not (exists folder "Hal 9000:Users:matthew:Desktop:Rejected Folder Done") then
                                                                                    set theLastFolder toduplicate foldericonto desktop
                                                                          else
                                                                                    set theLastFolder to folder"Hal 9000:Users:matthew:Desktop:Rejected Folder Done"
                                                                          end if
                                                                          delay 0.5
      move startFile to theLastFolder with replacing
                                                                end if
                                                      end try
                                            end repeat
                                  end repeat
                        end if
              end repeat
              try
                        if (count theLastFolder) is 0 then delete theLastFolder
              end try
    end tell
    to getUniqueName(someFile, someFolder)
         check if someFile exists in someFolder, creating a new unique file name (if needed) by adding a suffix
              parameters -          someFile [mixed]: a source file path
                                  someFolder [mixed]: a folder to check
              returns [list]:          a unique file name and extension
              set {counter, suffixes, divider} to {0, "abcdefghijklmnopqrstuvwxyz", "_"}
              set someFile to someFile as text -- System Events will use both Finder and POSIX text
              tell application "System Events" to tell disk item someFile to set{theName, theExtension} to {name, name extension}
              if theExtension is not "" then set theExtension to "." & theExtension
              set theName to text 1 thru -((length of theExtension) + 1) of theName -- just the name part
              set newName to theName & theExtension
              tell application "System Events" to tell (get name of files of folder(someFolder as text))
                        repeat while it contains newName
                                  set counter to counter + 1 -- hopefully there aren't more than 26 duplicates (numbers are easier)
                                  set newName to theName & divider & (item counter ofsuffixes) & theExtension
                        end repeat
              end tell
              return newName
    end getUniqueName

    There are numerous errors in your script, and it's a large script so there might be more, but these are the standouts for me:
    At line 48 you:
                                                                          set fileName to get name of startFile
    which is fair enough - you then use this to see if the file already exists in the destinationFolder. However, if it does the logic about how to deal with that is flawed.
    At line 56 you catch the error:
                                                                                    on error errmess number errnum -- oops (should probably check for a specific error number)
                                                                                              log "Error " & errnum & " moving file: " & errmess
                                                                                              set newName to my getUniqueName(fileName, fakeTrash)
                                                                                              set name of fileName to "this is a unique name" -- or whatever
                                                                                              set name of fileName to newName
      --Now move the renamed file to the fake trash
      move file fileName to fakeTrash
      --now move the startfile to destination folder
      move file startFile to destinationFolder
                                                                                    end try
    so let's focus on that.
    56: catch the error
    57: log the error
    58: generate a new unique filename
    59: change the name of fileName to some other string
    Hang on, wait a minute.... we already ascertained that at line 48 you defined fileName as a string object that indicates the name of the file. This is just a string. It's no longer associated with the original file... it's just a list of characters. Consequently you cannot set the 'name' of a string, hence your script is doomed to fail.
    Instead, what I think you want to do is set the name of the startFile to the unique string. Files have filenames, and therefore you can set the name.
    You have a similar problem on line 64 where you try to 'move file filename to fakeTrash'. fileName is just a string of characters. It isn't enough to identify a file - let's say the file name is 'some.psd'. You're asking AppleScript to move file some.psd to the trash. The question is which some.psd? The one on the desktop? in your home directory? maybe on the root of the volume? or maybe it should search your drive to find any/all files with that name? nope. None of the above. You can't just reference a file by name without identifying where that file is. So you probably want to 'move file fileName of destinationFolder...'
    There may be other problems, but they're likely to be related - all issues with object classes (e.g. files vs. strings), or not being specific about which object you want.
    As I said before, though, I might be way off - you don't say where the error is triggered to make it easy to narrow down the problem. Usually AppleScript will highlight the line that triggered an error. Knowing what that line is would help a lot.

  • Need to split Quicktime movie files

    Hi Group!
    I have a bunch of movie files (MPEG4) that I need to split.
    I'm thinking a workflow like this:
    - open movie in qt pro
    - create out-point at the 65 minute mark
    - cut it
    - create new movie
    - paste it
    - rename it to oldname_"Part1"
    - save it
    - close it without saving
    - rename remaining file to oldname_"Part2"
    - save it
    - close it without saving
    So far I have the split/cut/paste part working, but I can't figure
    out how to name a open movie file in Quicktime.
    (I'm new to all this, as you can tell, and the Library in the Script Editor
    for the Quicktime components did not really explain a lot to me).
    Any help appreciated!
    Thanks!

    Try something like this…
    click here to open this script in your editor<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">set save_folder to path to movies folder as Unicode text
    tell application "QuickTime Player"
    set my_movie to the front movie
    set my_file to save_folder & my suffixwith_extension(mymovie's name, "_Part2")
    save my_movie in my_file -- use for a reference to the original
    -- save self contained my_movie in my_file -- use for a portable file
    end tell
    to suffixwith_extension(filename, suffix)
    if file_name contains "." then
    tell (a reference to AppleScript's text item delimiters)
    set {tid, contents} to {contents, "."}
    set file_name to file_name's text items
    tell (a reference to file_name's item -2) to set contents to contents & suffix
    set {file_name, contents} to {file_name as Unicode text, tid}
    end tell
    else
    set file_name to file_name & suffix
    end if
    return file_name
    end suffixwithextension</pre>

  • Is it possible to make a .MOV file "un-downloadable"

    Hi there...
    I have a weird question - is it possible to make an online video (.MOV file) "un-downloadable"?
    I work at a college and a professor wants to post some videos within the school's public site. But, because of his concern with copyright, he wants to make it so the videos are impossible to download to the viewers' local machines.
    Is there any type of setting or code that can be put within the .MOV file that would allow this to happen?
    Thank you so much for any feedback you have!
    g4   Mac OS X (10.4.8)  

    Any browser viewed QuickTime file will be "cached" (stored on the viewing computer). This is how browser work (they keep a copy of every page element) to help speed up viewing.
    QuickTime 7 (Mac and PC version) even allows the user to set the size of this cache so movies can be viewed while "off line".
    True "streaming media" (served with special streaming server software) is not cached on the viewing machine so no local copy is made. Streaming Server (QTSS) is free software available from Apple.
    What your school probably really wants is a way to prevent "copies" of your files being used. This is nearly impossible as anyone that views the file could use screen capture software to get a copy. Even the true streaming version.
    I use Snapz Pro.
    You could use some type of "log on" Web page to help limit the audience.
    You could also use "skin track" movies which make screen capture a bit of a chore.
    http://homepage.mac.com/kkirkster/MTV/
    My example will open in QuickTime Player. Even Pro users are prevented from saving or editing the file because it is protected by an AppleScript droplet "Save As Un-Editable" and modified for Tiger and QT 7.
    Hope this helps you decide a plan.

  • File type/quick time movie file

    My iTunes library used to have a preponderance of mp3 files. Now these seem to have been converted to Quick Time movie files. This might have occurred during an update. What happened and what does it mean.
    Many thanks,
    Wells

    Wells,
    Unfortunately the page you mention (http://www.cminow.org/itunesapplescriptfixer.html) will not load.
    Give it a couple more hours or try:
    http://www.cminow.com/itunesapplescriptfixer.html
    That's my site, and I switched the IP address about four hours ago, and the DNS is probably still pointing to the wrong address. For some reason, the ".com" address changed over really fast (at Comcast anyway), but the ".org" one didn't.
    Here's the AppleScript:on open badfiles
    repeat with i in badfiles
    set the item_info to info for i
    --Change "mp3" to "mp2" in the following line for MP2 files:
    if (name extension of item_info is "mp3") and (folder of item_info is false) then
    tell application "Finder"
    --Change "MPG3" to "MPG2" in the following line for MP2 files:
    set file type of i to "MPG3"
    set creator type of i to "hook"
    end tell
    end if
    end repeat
    end open
    Just copy and paste that into the Script Editor in your AppleScript folder in Applications. Save it as an application. Then find one of the files that's giving you problems and drag it onto the application. It should change the type and creator and iTunes should be happy.
    In order to avoid this in the future, just download the MP3s directly onto your hard drive by control-clicking or right-clicking on the link to the MP3. Choose the menu item that downloads to disk. In Safair, it's "Download Linked File". That avoids the QuickTime Browser plugin, which is what gives it a type of "MPEG" and creator of "TVOD" instead of "MPG3" and creator of "hook", which is what iTunes is happiest with.
    Let me know if any of this wasn't clear, and I'll try to explain it better...
    charlie

  • I have QT Pro 7.6.6 and want to delete all audio (5 tracks) from a selected in-out section of a .mov file. Then, add new audio. How do I do that?

    I have QT Pro 7.6.6 and want to delete all audio (5 tracks) from a selected in-out section of a .mov file. Then, add new audio. How do I do that?

    If I 1) knew TeX well enough to fix it, and 2) could get the guy to answer the phone or email so as to give me the sourcecode or to fix it himself, I wouldn't have bothered figuring out that the thing could be fixed one page at a time by a) getting a copy of acrobat pro, b) figuring out how to turn on all of the extra toolkits, c) finding the edit object button in randomly named toolkit, d) right clicking on the chapter title and selecting the e) ever so obvious "delete clip" menu selection.
    At this point I would absolutely love to never have to touch an adobe product again in my life, but my hand has been dealt and if I'm going to print the manual for a software library that we've spent a cumulative $70,000 for, I have to figure this out and I really don't want to have to hit [Page Down], [Ctrl] + [A], Right click, delete clip for >700 pages.
    I felt certain that once I'd figured out how to shift the pages down using ghostscript so first two lines of each page weren't getting cut off in the printer non-printable region, and finally figured out this that a relatively simple scripting solution would be immediately apparant.  I mean, there are APIs for both applescript and javascript, but I'm mystified by how to get to the edit object feature from within them, much less how to tell that feature to delete clips for everything on a page.

  • Aliases of movie files in ~Movies/ for Front Row usage

    Hi everyone.
    In the first place I apologise for my bad English.
    I want one applescript for folder action wich will make an aliases of all movie files (.mov, .avi, .mpeg, .mpeg, .divx ,etc.) in freshly mounted CD/DVD/HD in ~Movies/ folder because I want to play those files in Front Row.
    Another Script is needed for deleting unwanted aliases upon unmounting that CD/DVD/HD.
    I figured out that all CD/DVD/HD are mounted in /Volumes folder, and I created such two scripts:
    On mounting drive:
    on adding folder items to this_folder after receiving these_items
    try
    tell application "Finder"
    make new alias file to these_items at "Macintosh HD:Users:USERNAME:Movies:" with properties {name:"Movie"}
    end tell
    end try
    end adding folder items to
    On unmounting drive:
    on removing folder items from this_folder after losing these_items
    try
    tell application "Finder"
    delete alias file "Macintosh HD:Users:USERNAME:Movies:Movie"
    end tell
    end try
    end removing folder items from
    I attached those two scripts as /Volumes folder action and they are working good, but there is a problem.
    When I mount CD, and then when I connect my iPod, alias of CD is moving to trash and new alias to iPod is created with same name. Also, when I connect iPod, and then CD and then I disconnect iPod alias to CD is moving to trash. ****, that's not quite what I am looking for.
    Apparently I have and idea, but I lack experience with applescript.
    Creating alias script should work like that:
    on mounting drive in filesystem
    1) Scanning about 2 levels for QT supported files
    2) Making alias to each movie file in those 2 levels in ~Movies/
    3) Adding constant Spotlight comment (for alias removing purposes in other script) to those alias files in ~Movies/
    Removing unwanted Aliases:
    on unmounting drive from filesystem
    1) Scanning ~Movies/ For alias files with constant spotlight comment
    2) removing those alias files (moving to trash preferably, for security purposes)
    This way script would make only good aliases, and there could be multiple drives mounting into system. Apparently, after unmounting any drive aliases with constant spotlight comment will be moved to trash, but I don't have any idea for that.
    Can someone help me?

    Hello imrik,
    Firstly, I don't use OSX myself, so the rest of this post is based upon my experience under OS9 and some knowledge from OSX documentations, etc.
    Folder Actions suite (terms for Folder Action's handler) is defined in StandardAdditions.osax, that is located at (probably):
    /Library/ScriptingAdditions/StandardAdditions.osax
    In brief, the dictionary states (under OS9):
    on adding folder items to fda after receiving aa
    -- fda is alias of the folder that receives new item(s)
    -- aa is list of aliase(s) the folder fda received
    end adding folder items to
    on removing folder items from fda after losing nn
    -- fda is alias of the folder that loses item(s)
    -- nn is list of aliase(s) or list of item name(s) the folder fda loses.
    end removing folder items from
    * Open the dictionary of the OSAX in Script Editor for more details.
    As far as I can tell (under OS9.1, AS1.8.3), 'removing folder items' handler always provides list of names that the folder loses, in spite of the description in OSAX dicitonary.
    I don't know the reason why 'removing folder items' handler provides {} in 'after losing' argument in your environment. It should provide list of names of unmounted volumes (unless '/Volumes/' directory is something so special as to deceive Folder Action Server in some way.)
    (Possibly your method to check the handler's arguments is not appropriate.)
    If you want to check the class of value/object in AppleScript, the proper way is to use a code such as SCRIPT1:
    -- SCRIPT1
    set x to (path to desktop) -- alias
    --set x to {1,2,3} -- list
    set c to class of x
    display dialog ("" & c) -- this will show class name string of x.
    return c -- this will return class of x in result window (when run in Script Editor).
    -- END OF SCRIPT1
    And to check the contents of value/object, you may try SCRIPT2 (for AppleScript's native value/object):
    -- SCRIPT2
    -- in target script (run in e.g. Applet or Folder Actions)
    set x to {1, 2, 3}
    tell application (path to frontmost application as text)
    activate
    set the clipboard to x
    end tell
    -- in checker script (run in Script Editor)
    set y to the clipboard
    return y -- y is given in result window of Script Editor.
    -- END OF SCRIPT2
    So as a whole, you may try something like SCRIPT3 as your test Folder Action and SCRIPT3A as its corresponding checker:
    -- SCRIPT3
    on adding folder items to fda after receiving aa
    tell application (path to frontmost application as text)
    activate
    set the clipboard to {fda, aa}
    display dialog ("" & (class of aa) & return & (class of (aa's item 1)))
    end tell
    end adding folder items to
    on removing folder items from fda after losing nn
    tell application (path to frontmost application as text)
    activate
    set the clipboard to {fda, nn}
    display dialog ("" & (class of nn) & return & (class of (nn's item 1)))
    end tell
    end removing folder items from
    -- END OF SCRIPT3
    -- SCRIPT3A (to be run in Script Editor)
    set y to the clipboard
    return y -- clipboard contents is displayed in result window of Script Editor.
    -- END OF SCRIPT3A
    That's all for now.
    Good luck,
    H
      Mac OS 9.1.x  

  • Applescript movie duration timecode to frames

    Hi all
    2 Questions
    FIRST QUESTION
    in a text file I have the movie names and their timecode duration
    I hope to convert the timecode duration to the equivalent frame count.
    Every movie time base is 25 frames per seconds
    My text file has the Movie filename a tab and the timecode. This is just an example
    MOVIE1.MOV [TAB] 00:02:12:05
    MOVIE2.MOV [TAB] 00:04:02:12
    MOVIE3.MOV [TAB] 00:00:32:19
    How to convert this to a new file as follows?
    movie filename tab and frames count
    MOVIE1.MOV [TAB] XXXX Frames
    and so on?
    The file list is rather long with over 625 different takes ....
    SECOND QUESTION
    How to ask Quicktime Player 7 to open a movie file and place the playhead at a given frame?
    thanks a lot
    Dan
    Message was edited by: etnad for spelling

    Thanks Hiroto
    both your script work perfectly, I want to explain what we are trying to achieve.
    We are using FilemakerPro database as a pre-editing tool for a film we shoot
    Too complex here to explain the serious reasons for this choice
    The scripts in reply to the first question allows us to create a frame field in FMP to then choose various different starting points in our film-files.
    We use successfully this FMP and Applescript combined script from within filemaker to open clips we choose from our FMP file:
    Let (
    mac_path = Right ( Substitute ( Media Path; "/"; ":"); Length (Media Path) - 1);
    "tell application \"Quicktime 7\"" & ¶ &
    "activate" & ¶ &
    "open " & Quote ( mac_path ) & ¶ &
    set the dimensions of movie 1 to {480, 270}
    "end tell"
    the script calls the clip in QT and plays it
    we use the script to open more than one QT window to compare takes as QT allows to see more than one film at the time,
    While your script works perfectly from within Filemaker as "Native Applescripts" playing from the starting point set in the script, I am not able to adapt it in the one we use already. we need to merge them to use some of the fields in my database for the frame_number required.
    Adding this information to the original working script, Quicktime opens the film and gives an error telling it cannot set the playhead to the frame and stops before changing the film dimensions.
    This is what I did
    Let (
    mac_path = Right ( Substitute ( Media Path; "/"; ":"); Length (Media Path) - 1);
    "set frame_number to "  & Frames & ¶ &
    "tell application \"Quicktime 7\"" & ¶ &
    "activate" & ¶ &
    "open " & Quote ( mac_path ) & ¶ &
    "set current time to frame_number" & ¶ &
    "set the dimensions of movie 1 to {480, 270}" & ¶ &
    "end tell"
    Is there a way to fit parts of your scripts in FMP?
    Regards
    Dan

  • HT2488 Hot to auto-rotate movie files

    Hello, I have a relatively simple operation that I can't seem to figure out using automator:  I want to create a droplet that rotates any movie files selected by 180 degrees. I can do this manually using QuickTime 7, not QT X, but it's tedious for multiple files.
    Manually, I open the movie file (a ProRes clip) in QT7, hit command J to open movie properties.
    Select 'Video Track'
    Select 'Visual Settings' tab.
    Click on the rotate 90 degrees button (either rounded arrow) twice.
    Then save, exit and repeat.
    Is this possible to do in automator?  I've looked into other auto-rotating programs, but they all involve re-rendering and way too much time and diskspace for what is a very simple operation in QT7.
    Any thoughts on the matter are greatly appreciated.
    Thank you,
    Josh

    Paste this into AppleScript Editor, save it as an Application, drop some movies on it.
    on open theFiles
        try
            repeat with afile in theFiles
                tell application "QuickTime Player 7"
                    open afile
                    rotate document 1's track "Video Track" by 180
                    close document 1 with saving
                end tell
            end repeat
        on error errMsg number errNum
            display alert errMsg & return & return & "Error number" & errNum buttons "Cancel"
        end try
    end open

  • Hi everybody, I am trying to create a DVD pal without menu with the program iDVD from a .mov file. Any ideas? Thanks so much.

    Hi everybody, I am trying to create a DVD pal without menu with the program iDVD from a .mov file. Any ideas? Thanks so much.

    (From fellow poster Mishmumken: )
    How to create a DVD in iDVD without menu (there are several options):
    1. Easy: Drop your iMovie in the autoplay box in iDVD's Map View, then set your autoplay item (your movie) to loop continously. Disadvantage: The DVD plays until you hit stop on the remote
    2. Still easy: If you don't want your (autoplay) movie to loop, you can create a black theme by replacing the background of a static theme with a black background and no content in the dropzone (text needs to be black as well). Disadvantage: The menu is still there and will play after the movie. You don't see it, but your disc keeps spinning in the player.
    3. Still quite easy but takes more time: Export the iMovie to DV tape, and then re-import using One-Step DVD.
    Disadvantage: One-Step DVD creation has been known to be not 100% reliable.
    4. (My preferred method) Easy enough but needs 3rd party software: Roxio Toast lets you burn your iMovie to DVD without menu - just drag the iMovie project to the Toast Window and click burn. Disadvantage: you'll need to spend some extra $$ for the software. In Toast, you just drop the iMovie project on the Window and click Burn.
    5. The "hard way": Postproduction with myDVDedit (freeware)
    Tools necessary: myDVDedit ( http://www.mydvdedit.com )
    • create a disc image of your iDVD project, then double-click to mount it.
    • Extract the VIDEO_TS and AUDIO_TS folders to a location of your choice. select the VIDEO_TS folder and hit Cmd + I to open the Inspector window
    • Set permissions to "read & write" and include all enclosed items; Ignore the warning.
    • Open the VIDEO_TS folder with myDVDedit. You'll find all items enclosed in your DVD in the left hand panel.
    • Select the menu (usually named VTS Menu) and delete it
    • Choose from the menu File > Test with DVD Player to see if your DVD behaves as planned.If it works save and close myDVDedit.
    • Before burning the folders to Video DVD, set permissions back to "read only", then create a disc image burnable with Disc Utility from a VIDEO_TS folder using Laine D. Lee's DVD Imager:
    http://lonestar.utsa.edu/llee/applescript/dvdimager.html
    Our resident expert, Old Toad, also recommends this: there is a 3rd export/share option that give better results.  That's to use the Share ➙ Media Browser menu option.  Then in iDVD go to the Media Browser and drag the movie into iDVD where you want it.
    Hope this helps!

  • Working on a script to search for and move files - need Guru help!

    Hi, I'm trying to help my dad with a task and my outdated Applescript knowledge isn't helping me much.
    Here's what I need to do in a nutshell:
    FolderA contains a bunch of JPG files.
    FolderB is the root of a hierarchy of folders containing DNG files.
    Each file of FolderA has a mating file (same name but with .DNG) somewhere in the hierarchy of FolderB.
    The goal is to move each JPG file from Folder A to the folder containing it's mate.
    So, the basic flow is:
    1. Get list of files in folderA
    2. Looping through list, strip out file name (fileA) and find the DNG file somewhere inside FolderB
    3. Get the path of the folder containing the matching DNG file
    4. Copy/move FileA to the folder.
    5. Loop back to #2
    OK, so here's where I am:
    tell application "Finder"
    set JPEGfolder to "Macintosh HD:DadTest1:DadA"
    set DNGfolder to "Macintosh HD:DadTest1:DadB"
    set a_list to every file in Afolder
    repeat with i from 1 to number of items in a_list
    -- Everything happens within this loop
    set a_file to (item i of a_list)
    set fileInfo to info for a_file
    set theName to displayed name of fileInfo as string
    -- now theName contains the actual file name minus the extension
    At this point I don't know how to search for the mating file using Applescript. If I was in UNIX I could do a "find . -name filename" and parse out the path, but I don't know how this works in Applescript.
    I think I can figure out how to move the file once I have the path, but the search routine has me stumped for now.
    Any thoughts?
    Thanks!

    In my opinion your best bet is to take a 180° turn and simplify things significantly.
    Your current approach involves multiple file searches - for each file in the JPEG folder, search all the DNG folders looking for a match. That's an large number of searches, and a large number of something that AppleScript isn't great at.
    Instead you'd be far better off walking once through the DNG folders. For each DNG file look for a matching JPG file in the one folder that contains JPEGs. This would be exponentially faster - one walk through the filesystem vs. one walk through the filesystem for every JPEG.
    This should give you an idea of what I'm talking about (untested):
    global JPEGfolder
    on run
      set JPEGfolder to alias "Macintosh HD:DadTest1:DadA"
      set DNGfolder to alias "Macintosh HD:DadTest1:DadB"
      processAFolder(DNGfolder)
    end run
    on processAFolder(theFolder)
      tell application "Finder"
        repeat with eachItem in folder theFolder
          if class of eachItem is file and name extension of eachItem is "dng" then
            set basename to characters 1 through -5 of (get name of eachItem)
            try
              move file (basename & ".jpg") of folder JPEGfolder to folder theFolder
            end try
          else if class of eachItem is folder then
            my processAFolder(eachItem)
          end if
        end repeat
      end tell
    end processAFolder
    The idea here is that you start off in the top folder and iterate through each item. If the item is a file and it's name extension is DNG then try to move a corresponding file from the JPEG folder to the current folder. This is wrapped in a try block so the script doesn't fail if there is no corresponding JPG.
    If the current item is a folder then the script descends into that folder by calling itself.

Maybe you are looking for