Applescript: isn't in the correct format?

Hi, i wanted to make a script that would randomly take an image from a fodler of life drawing models and landscript that i would then have to draw.
Everything seemed to be working fine with it but all of the sudden im getting 2 different messages whenever the script is run.
The first message i get is:
The file couldn’t be opened because it isn’t in the correct format.
The file might be corrupted, truncated, or in an unexpected format.
I went to the image that wasn't working and double clicked it and it opened fine in Preview.app so i wasn't sure why it wasn't working with the script but was with the double click.
the other message im getting is a permissions message but i can't seem to get that to come back up at the moment to copy and paste it here, but it looks like the normal "you do not have permission to view this file" sort of thing.
i've checked permissions and i've repaired them just encase but no issues or warning came up so im not sure what the issue with the permissions could be.
here is the script i have used to make it select and open a random image.
with timeout of 36000 seconds
    tell application "Finder"
        activate
        if (count items) of folder "MonkeyBook Pro:Users:Monkey:Documents:Guardian Classes:Drawing Tasks:" is 0 then
            display dialog "You Have Completed All Available Drawning Tasks, Please Add More To Folder" with icon stop buttons {"Open Folder", "Random Image Site", "Close"}
            set the button_pressed to button returned of the result
            if the button_pressed is "Open Folder" then
                tell application "Finder"
                    activate
                    open "MonkeyBook Pro:Users:Monkey:Documents:Guardian Classes:Drawing Tasks"
                end tell
            else if the button_pressed is "Random Image Site" then
                tell application "Safari"
                    activate
                    open location "http://photo.net/photodb/random-photo?category=NoNudes"
                end tell
            end if
        else
            activate
            set question to display dialog "Time For Some Drawing
Warning These Photos May Be Of An Adult Nature" with icon stop buttons {"Not Possible At The Moment", "OK"}
            set answer to button returned of question
            if answer is equal to "OK" then
                tell application "Finder"
                    set randomImage to some file of folder "MonkeyBook Pro:Users:Monkey:Documents:Guardian Classes:Drawing Tasks"
                end tell
                tell application "Preview"
                    open randomImage
                end tell
                tell application "Finder"
                    move randomImage to folder "MonkeyBook Pro:Users:Monkey:Documents:Guardian Classes:Completed Tasks:"
                end tell
            end if
        end if
    end tell
end timeout
Anyone got any idea why this might be happening?

I think the issue comes from the fact that the picture is moved to the Completed Tasks folder before Preview.app has had time to open it properly. So, if I'm right, adding a short delay before moving the picture should fix the issue.
Maybe you might want to try this simplified version of your script:
set DrawingTasks to POSIX file "/Users/Monkey/Documents/Guardian Classes/Drawing Tasks"
set CompletedTasks to POSIX file "/Users/Monkey/Documents/Guardian Classes/Completed Tasks"
tell application "Finder"
    activate
    if (count items of folder DrawingTasks) is 0 then
        display dialog "You Have Completed All Available Drawning Tasks, Please Add More To Folder" with icon stop buttons {"Open Folder", "Random Image Site", "Close"}
        set the button_pressed to button returned of the result
        if the button_pressed is "Open Folder" then
            open folder DrawingTasks
        else if the button_pressed is "Random Image Site" then
            tell application "Safari"
                activate
                open location "http://photo.net/photodb/random-photo?category=NoNudes"
            end tell
        end if
    else
        set question to display dialog "Time For Some Drawing." & return & return & "Warning: These Photos May Be Of An Adult Nature" with icon stop buttons {"Not Possible At The Moment", "OK"}
        set answer to button returned of question
        if answer is equal to "OK" then
            set randomImage to some file of folder DrawingTasks
            tell application "Preview" to open randomImage
            delay 2 -- adjust to fit your needs
            move randomImage to CompletedTasks
        end if
    end if
end tell

Similar Messages

  • Cannot open a downloaded pdf file..."The file couldn't be opened because it isn't in the correct format."

    I have had this problem several times lately: I cannot open a downloaded pdf file. The error message reads: "The file couldn't be opened because it isn't in the correct format." But, of course, it is a pdf file.

    My MacBook Pro (2.5 Ghz Intel Core i5) is running OS X 10.9.4. Here is what happens when reading an online user manual that I want to save to the Desktop and read later as a PDF file on my iPad or phone. With Safari I will select "Export As PDF" and the file shows up on the desktop. Even after multiple trials, there will be a dialogue box indicating the file cannot be opened. If I check the file info, the size is "zero." Trying to save the file as a pdf using the Print menu yields the same results. I have tried both of these methods using Preview, Adobe Reader, and PDF Pen Pro. This strange behavior also occurred several weeks ago and I finally abandoned the effort. But when the same thing happens twice, it becomes an issue that needs to be resolved.

  • HT200261 Configurator Error. Apple Configurator could not open your library.The file couldn't be opened because it isn't in the correct format.

    I was using configurator without trouble.  Unfortunately, my battery died and my computer went down.  I plugged my computer in, restarted it and tried to open configurator.  Now this is the error I am getting.  Apple Configurator could not open your library.The file couldn’t be opened because it isn’t in the correct format.  How do I fix this?

    Thank you for responding. The number 2 after the file final cut events is temporary so I can copy it to another drive while I am working on this.  . i got a new message that reads...
    Final Cut Pro must restore or move corrupted databases before opening.

  • I exported my iBook and got the .ibooks file on my Desktop(iMac Retina 5K), I tried to put the file into the iBooks application but I get a message that says "The file "______.ibooks" couldn't opened because it isn't in the correct format.

    I exported my iBook and got the .ibooks file on my Desktop(iMac Retina 5K), I tried to put the file into the iBooks application but I get a message that says "The file "______.ibooks" couldn't opened because it isn't in the correct format.  I took the same file and transferred it in my MacBook Air and was able to put it in the  iBooks application no problem, the MacBook Air runs OS X v 10.9.5
    Please advise as to Why it would work on an older OS X version as oppose to the newer OS X Yosemite
    Thanks
    JP

    Thanks Lyra,
    I may be doing something wrong because looking at the "Purchased" in iBooks I only see all the books that I actually purchased, none of the iBooks that I created in iBooks Author shows up. I can re-download all the iBooks I've purchased and some in iCouds, but the ones I've created  in iBooks Author are no where to be found.
    Any help is much appreciated,
    Best Regards,
    JP

  • Cannot open Pages documents that I've worked on.  I open a new document, work on it, then save and close it.  When I try to open the document again, I get the following message: The document "[name]" could not be opened. The file isn't in the correct form

    I cannot open Pages documents that I have worked on and saved.  When I try to reopen Pages documents that I've saved, I get the following
    message:
    "The document “[name of document]” could not be opened. The file isn’t in the correct format.
    The file might be corrupted, truncated, or in an unexpected format."
    I have downloaded the latest update to iWork, but that doesn't help.
    I use Mac OSX 10.6.7
    I am using Pages '09 version 4.0.5 (852)
    If anyone can help, I would greatly appreciate it.
    Best regards,
    New York Mac User

    A few general trouble shooting tips that may apply here:
    1. If you used Software Update to do the OS update(s) to reach 10.6.7, go to http://support.apple.com/downloads/ and download and apply the Mac OS v10.6.7 Combo Updater. The Combo Updater contains some fixes that were not included in the incremental updaters used by Software Update.
    1a. Check that you have the current version of Pages (and of the other iWork applications) installed. All three applications' current version numbers end in .0.5
    2. A common cause of malfunctioning applications is a corrupted preferences file (.plist file). Your Pages '09's plist is at yourname > Library > Preferences > com.apple.iWork.pages.plist
    Quit Pages, locate the file and Drag it to the Desktop (or to the Trash).
    Restart Pages and attempt to open one of the files.
    If all is well, Trash the plist file and empty the Trash.
    If there's no change, AND you've made changes to the Preferences that you wish to keep, drag the file back to its previous location, replacing any new one that has been created.
    Regards,
    Barry

  • I recently set up multiple accounts and when I was trying to figure out how to share files I messed up something in my documents. Everytime I open a doc from the ADMIN account, a box pops up that says "The file is not in the correct format" how to fix?

    I recently set up multiple accounts on my imac, When I was trying to figure out how to share the documents I must have done something wrong. When logged into the Admin account, I open up any document and I get a message box that says, "The Document could not be opened. The file isn't in the correct format. The file might be corrupted, truncated, or in an unexpected format." What did I do and how do I fix it?

    Without knowing what you did it is impossible to give advice on how to correct it.
    If these were files you copied over from some other system then just Re-Copy them replacing the ones that are corrupted.
    Other then that I suggest you Wipe the drive and start over with a clean reinstall of the OS and programs. Then if you want to share files to All Accounts place those files in a folder in the ROOT of the drive.

  • I have a MacBook Pro, I want to copy Itunes files to an SD card to play in my car, the SD Card doesn't appear in Itunes when I insert it, and I don't know how to convert the files to the correct format, can anyone help?

    I have a MacBook Pro, I want to copy Itunes files to an SD card to play in my car, the SD Card doesn't appear in Itunes when I insert it, and I don't know how to convert the files to the correct format, can anyone help?
    Thank you

    So it seems from reading the COMMAND manual that my first issue is that I used a 16GB SD card, and the manual says it will only recogize up to a 2GB SD card. I did use my MB Air's SD card slot and crated a folder and dragged the music files to it, then to the card. So I am going to get a 2GB card and try that next. Otherwise just stick with the iPOD connected. At least that is 8GB

  • I'm trying to create a Windows partition using Boot Camp. An error comes up telling me that I need to reformat my current partition(s) into one single partition. However, it's already formatted in the correct format, and is already a single partition.

    As made clear in the title:
    I'm trying to create a Windows partition using Boot Camp. An error comes up telling me that I need to reformat my current partition(s) into one single partition. However, it's already formatted in the correct format, and is already a single partition.
    My computer recently had a kernel panic, which apparently the corruption was in the system and needed to be erased and re-installed. I have a complete back-up using an external hard drive, and I am definitely not willing to do another one of those to reformat a partition that is already singular. I restarted the computer after ejecting my back-up, and after turning off time machine (thinking that boot camp was recognizing it as a secondary partition), however the error still occurs.
    Is there any way to get around this?

    diskutil list:
    /dev/disk0
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *750.2 GB   disk0
       1:                        EFI                         209.7 MB   disk0s1
       2:                  Apple_HFS Macintosh HD            749.3 GB   disk0s2
       3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
    /dev/disk1
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:                            Windows7               *2.9 GB     disk1
    diskutil cs list:
    No CoreStorage logical volume groups found
    mount:
    /dev/disk0s2 on / (hfs, local, journaled)
    devfs on /dev (devfs, local, nobrowse)
    map -hosts on /net (autofs, nosuid, automounted, nobrowse)
    map auto_home on /home (autofs, automounted, nobrowse)
    /dev/disk1 on /Volumes/Windows7 (udf, local, nodev, nosuid, read-only, noowners)
    From my very basic knowledge - it still looks as if there is only one partition (not including the windows 7 CD necessary to install the windows partition).

  • What is the correct format of filepath string on Mac os x?

    I am trying to retrieve a file from Mac os x by:
    File file=new File(filepath);
    My boot volume name is "myVol", and filepath is "/myVol/opt/ab.txt". However, when I provide this path, the file is not found. I just figured out that if I use "/opt/ab.txt" the correct file can be found!!
    Now, if I have a shared volume on my machine(I got it by menu "Go-->Connect to Server..."), whose name is "Mac Share", the filepath should be something "/Mac Share/test/123.txt". File file=new File("/Mac Share/test/123.txt") can not find the file. It looks like that it's trying to find 123.txt from /myVol/Mac Share/test directory, which doesn't exist. I even tried "//MacShare/test/123.txt", "Mac Share/test/123.txt", etc., and none of them worked!!
    If you know the correct format to specify the filepath on Mac OS x, please give me help!!!!
    Thanks in advance.

    I don't know the exact answer to your question, but you can probably figure it out on your own like:
    1) Create a File object that represents an existing file. Play around with the path until the file can be found.
    2) Now that you have a File object representing a valid, existing path, use MyFile.getAbsolutePath() to see what the full path string is. MyFile.getCanonicalPath() might provide some answers as well.
    Whatever getAbsolutePath() returns is the correct format for the file path string.

  • Every time I try to download the new version of Adobe Flash Player it saves as a .txt file and I do not know how to get it to save in the correct format.

    Every time I try to download the new version of Adobe Flash Player it saves as a .txt file and I do not know how to get it to save in the correct format.

    Please post in the Adobe Flash Player forum.

  • Problems with LDAP: "LDAP server prefix is not of the correct format"

    Hello!
    We use a Mac OS X Server (10.4.9) with Open Directory for authentication of the clients in our network. Furthermore, that machine serves home directories and mobile accounts.
    Every now and then a client hangs during login: After submitting login information, the system does not respond anymore (shows 'hourglass'). A few minutes later, the login process continues.
    The system log on the client contains the following lines:
    Apr 12 08:31:16 hostname kernel[0]: System Sleep
    Apr 12 08:31:16 hostname kernel[0]: Enabling XMM register save/restore and SSE/SSE2 opcodes
    Apr 12 08:31:16 hostname kernel[0]: Started CPU 01
    Apr 12 08:31:16 hostname kernel[0]: IOBluetoothHCIController::restartShutdownWL this is a wake from sleep
    Apr 12 08:31:16 hostname kernel[0]: System Wake
    Apr 12 08:31:17 hostname kernel[0]: AppleYukon - en0 link active, 100-Mbit, full duplex, symmetric flow control enabled
    Apr 12 08:31:18 hostname DirectoryService[53]: Search connection failure: During an attempt to bind to [X.Y.235.104] LDAP server.
    Apr 12 08:31:18 hostname DirectoryService[53]: Search connection failure: Disabled future attempts to bind to [X.Y.235.104] LDAP server for next 120 seconds.
    Apr 12 08:31:24 hostname kernel[0]: AFPSleepWakeHandler: waking up
    Apr 12 08:31:43 hostname DirectoryService[53]: DSLDAPv3PlugIn: DHCP option 95 error since obtained [X.Y.235.32] LDAP server prefix is not of the correct format.
    Apr 12 08:31:44 hostname /System/Library/CoreServices/MirrorAgent.app/Contents/MacOS/MirrorAgent: LWNotifyWithData: CFMessagePortSendRequest returned error -2.
    Apr 12 08:35:33 hostname DirectoryService[53]: Search connection failure: During an attempt to bind to [X.Y.235.104] LDAP server.
    Apr 12 08:35:33 hostname DirectoryService[53]: Search connection failure: Disabled future attempts to bind to [X.Y.235.104] LDAP server for next 120 seconds.
    Apr 12 08:36:04 hostname kernel[0]: AFP_VFS afpfs_mount: /Volumes/Users, pid 256
    What is the cause for that failure?
    Regards, Martin Burger
    iMac 20" (2 GHz Intel Core Duo) Mac OS X (10.4.9) Server: Dual 2.5 GHz PowerPC G5 with Mac OS X Server (10.4.9)

    Don't do DHCP based binding, configure it manually.
    -Ralph

  • What is the correct format for localhost URL?

    I've installed MAMP to run a local test server.
    This appears to be working correctly with the URL in the following format:
    http://localhost/folder/filename.php/
    Where folder is the folder for the site located inside the Apache Document Root Folder - as defined in the MAMP preferences.
    I have web sharing turned off.
    Looking around the web it seems that the format for the URL should be:
    http://localhost/~username/folder/filename.php
    However, when I insert "~username" in the URL the browser can't find the page.
    These are my first tentative steps in setting up a local test server and so I'm concerned that something might be amiss!
    I've hunted around and can't find any documentation that clarifies the issue.
    Can anyone clarify the issue or point me to appropriate documentation.
    Thanks.

    The second format is for a different location - in your Home folder.  This would work if; a. Apache was installed using the Home folder; and b. if "folder" existed in the Home folder.  Use the form you are currently using since it works.

  • Transfering music in the correct format

    how do I tranfer music to an sd card in mpr format in only seems to let me save in xml format and my in car mp3 can not read it can you help

    The export function in itunes only exports a text file of the music titles you have in your library.
    If you want to put the actual music files onto your sd card, you will need to drag and drop the music from the itunes library window to any location you want.
    The drag and drop does not remove the song from the library, just copies it.
    Then you can move the music files onto your sd card.
    Now if the music in your itunes library is purchased from the itunes music store, it will not be in the mp3 format. Also, unless the music is itunes+, you cannot convert to mp3.
    Here is an article from the apple support website on changing music format.
    http://docs.info.apple.com/article.html?artnum=93123

  • I've bought Mountain Lion but my iMac's HD isn't the correct format (Mac OS Extended(Journaled) instead of GUID partition what do I do?

    Can I just back up to Time machine, then reformat disk then re down load?

    As mende1 stated, the two are different and must be both.
    If you open Disk Utility and select the hard drive (the type, size, and serial number), not the volume (Macintosh HD), it will tell you at the bottom of the screen what the Partition Table is. It should be GUID. If not, then you will need to back it up, then repartition the drive. Also, copy the Mountain Lion installer onto another drive so you don't have to download again. It is in the Applications folder.
    There are a few methods to get back where you are, including wipe, install old OS, restore from TM, install ML.
    You might search the web for a tutorial on creating a boot/install disk using the Mountain Lion installer.
    Another easy way is to use something like Carbon Copy Cloner or SuperDuper to clone your current OS onto another drive. Then, boot using the external you cloned. Use Disk Utility to re-partition the internal drive as noted below, then Clone your current OS back to the internal. Then, use the installer you tucked away to reinstall.
    If running Snow Leopard, you need to boot using your install disk, then open Disk Utility.
    If running Lion, you need to boot into the Recovery HD by holding down cmd-r on restart.
    From there, open Disk Utility, select the hard drive, then the Partition tab.
    Select 1 partition from the partition layout dropdown (or however you'd like, just don't use current).
    Set the Name of the disk. Macintosh HD is the norm, but you can name it anything you want.
    Set the Format to Mac OS Extended (Journaled)
    Click the Options Button.
    Set the Partition Table to GUID Partition Table.
    Back on the partition tab, click Apply.

  • MSS - Data from forms not pulling in in the correct format

    Good day,
    I recently created a new interactive adobe form which allows a manager to input data to change the work schedule rule of an employee. For a particular field in the form, we are experiencing an issue - the data that is input on the form to change IT007 (employment %) is being pulled into ECC in a different format.
    On the form, the employment % input field can be typed in as a 2 digit number. For example, a manager may input "50" on the form to indicate that their employee should be part time with an employment percentage of 50%. This feild value remains as a 50 - up until we try to process the form via the PA40 action.
    Once the form data is being pulled into the PA40 action (change in work schedule), IT007 now pulls in from the form with a value of 0.50 when it should be 50.00.
    All our other interactive forms such as the transfer is working correctly for IT007 with the value pulling as 50.00 - Also, this new form is based off of this transfer form so it's kind of puzzling.
    Any help would be greatly appreciated.
    Thanks,
    Christine

    << Do not post the same question across a number of forums >>

Maybe you are looking for

  • Extend Provisioning (from OIM to OID) for already provisioned resources

    We use OIM 9.1.0 to provision users to several target systems, for example OID. Not all information stored for a user in OIM is also provisioned to OID (for example department or location or phone is only stored in OIM). The provisionig task automati

  • User Authorization for a Query

    Hi, I have assigned a single role to a user, in which I have authorization for all the Infoproviders, including authorization for reporting. The user is able to access most of the queries, except one query. If there is a problem, he should not have a

  • Check inactive accounts of ACS for a specified period

    Hi all, Is it possible to find out which are the inactive accounts for eg 1month within the ACS GUI? TIA!

  • Random Shutdown & Random Screensaver Hang

    I left my Macbook, all updates installed, on last night to convert some video to DVD and burn the disk. I woke up this morning to find it wswitched off. The power settings are set to never turn off, and nothing sceduled either. None of the software r

  • Starting over from scratch

    OK, iCal and Entourage are not playing along nicely in the least. I had to rebuild Entourage's database, and it started working fine again. But as soon as I turned on the Syncing Services with iCal, Entourage beachballs again. So I think I should do