I’m frustrated

How do I make the Applescript move command work?

On p. 90 of AppleScript: The Missing Manual, first ed. is a sample script for moving all the desktop files and folders to a new home folder. The script compiles but will not run. This was reported on the errata page of the O’Reilly website under “Unconfirmed Errata”. I get exactly the same error message as reported there.

I tried saving the script as an application and then running it from the Desktop. That didn’t work either. I am really a newbie in Applescript. I have no clue as to how to proceed to get around this bottleneck.

Can anyone help?

iMac: OS X 10.5.6
processor: 2.66 GHz Intel Core2 Duo
memory: 2 GB 1067 MHz DDR3
1 person has
this question
+1
Reply
  • I’m excited
    Guess what.

    I found my own solution to the problem on p. 90 of Applescript: The Missing Manual and the move command.

    It seems that OS X considers drives on the desktop as folders. And OS X is not going to allow you to move them to another folder down the line.

    So the solution is to prevent your script from including these folders in the move list. In my case there were three “Macintosh HD”, my backup hard drive: “Backup”, and “Keep1” a flash drive. In the included script you will note my move list starts with item 4 of allFolders. The repeat loop then peels off the folders one at a time and moves them.

    tell application "Finder"
    if not (the folder "MyDesktop" of home exists) then
    make new folder at home with properties {name:"MyDesktop"}
    end if
    set allFolders to the name of every folder in desktop
    set shortList to items 4 thru 18 of allFolders
    repeat with currFolder in shortList
    move folder currFolder to the folder "MyDesktop" of home
    end repeat
    move every file of the desktop to the folder "MyDesktop" of home
    end tell

    If anyone has a more elegant solution I would be glad to see it.

    BruceHG
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • How do I move a file from desktop to a folder in "Applications"
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited