Iconizer

Discussion in 'AppleScript' started by Walrus666, Nov 5, 2007.

  1. Walrus666

    Walrus666 Moderator

    Joined:
    Jul 21, 2007
    Messages:
    1,252
    Likes Received:
    15
    Location:
    Chicago
    Hello, here's a pretty cool Apple Script that you might enjoy. I call it the "Iconizer". It transfers icons from files and folders to other files and folders and vice versa. I also threw in the Iconizer app and some cool folders to practice with. Enjoy!
     

    Attached Files:

    Walrus666, Nov 5, 2007
    #1
    1. Advertisements

  2. Walrus666

    Walrus666 Moderator

    Joined:
    Jul 21, 2007
    Messages:
    1,252
    Likes Received:
    15
    Location:
    Chicago
    Perhaps I should paste the script here for those who are a bit apprehensive of downloading. The script has one annoying limitation, however. If the source object is a jpeg with a generic icon (See attachment 1), the generic icon will be transferred to the target object. I have a shell script (sips -i "$@") that I made in to an app called "PictureIconizer" (See attacment 2) that I'd like to add to this Apple Script, which should solve this limitation, when I have the time (In the U.S. it's work, work and work!). Perhaps Ric could knock this out for us if he'd be so kind. Here's the Iconizer Apple Script-


    on run {}
    set theSourceObject to my DetermineLocationOfObject("source")
    set theTargetObject to my DetermineLocationOfObject("target")
    my ApplyCustomIcon(theSourceObject, theTargetObject)
    end run

    to DetermineLocationOfObject(ObjectType)
    display dialog "Is the " & ObjectType & " object going to be a file or a folder?" buttons {"File", "Folder"} default button 2
    if button returned of the result is equal to "File" then
    set theObject to choose file with prompt "Please locate the " & ObjectType & " file."
    else
    set theObject to choose folder with prompt "Please locate the " & ObjectType & " folder."
    end if
    return theObject
    end DetermineLocationOfObject

    to ApplyCustomIcon(SourceObject, TargetObject)

    my HandleInfoWindow("source", SourceObject)
    my HandleInfoWindow("target", TargetObject)

    end ApplyCustomIcon

    to HandleInfoWindow(ObjectType, theObject)

    tell application "Finder"
    activate
    set InfoWindow to name of (open information window of item theObject)
    end tell

    tell application "System Events"
    tell application process "Finder"
    tell window InfoWindow
    keystroke tab
    if ObjectType is equal to "source" then
    keystroke "c" using command down
    else
    keystroke "v" using command down
    end if
    end tell
    end tell
    end tell

    tell application "Finder"
    close window InfoWindow
    if ObjectType is equal to "target" then display dialog "Icon transferred." buttons {"OK"} default button 1 giving up after 5
    end tell

    end HandleInfoWindow
     

    Attached Files:

    Walrus666, Nov 9, 2007
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.