AppleScript to handle the original file when I add an alias to a folder

I'm looking for a Folder Action to solve this problem:
When I add a file to a specific folder (the files added to this folder are always aliases), I want the original file of the alias to get his label color setted to another color.
How can I do this?
Jean-François

Hello
You may try something like the following script.
    This script can be run in three ways -
    [1] run as automator folder action; argv = {input, parameters} where input is alias list added to folder
    [2] run in editor; argv = script (self)
    [3] run as applescript folder action; argv = alias list added to folder
on run argv
    if argv's class = list then -- [1]
        _main(argv's item 1)
    else -- [2]
        choose file of type {"com.apple.alias-file"} with multiple selections allowed
        _main(result)
    end if
end run
on adding folder items to d after receiving argv -- [3]
    _main(argv)
end adding folder items to
on _main(argv)
    script o
        property |LABEL| : 4
            0   none
            1   orange
            2   red
            3   yellow
            4   blue
            5   purple
            6   green
            7   gray
        property aa : argv
        repeat with a in my aa
            set a to a's contents
            tell application "Finder"
                if item a's class = alias file then
                    set item a's original item's label index to |LABEL|
                end if
            end tell
        end repeat
    end script
    run script o
end _main
Briefly tested under OS X 10.6.8.
* Note that folder action can be very slow to be triggered.
Regards,
H

Similar Messages

  • Where does InDesign CS4 get the name for the .icml file when using "Add to Assignment"?

    I'm trying to figure out a larger problem with InDesign and InCopy files and was curious about where the names comes from. When I add a story to an assignment it doesn't ask me for a name. It seems it is using a name from sometime in the document's past.

    Found it...
    ${bindings.XXXXXX.path}Found it when trying out LOV's... The messageLovInput node uses it to populate it's id.
    Regards,
    Robert

  • On some of my files there is a ! in front of it, if I try to play the song, I get an error message; "The song "_____" could not be used, because the original file could not be found. Would you like to locate it?" Then when I click "Locate", I get nothing.

    I'm really dumbfounded on this one and it's driving me bonkers!!!! On some of my music files there is a ! in front of it, if I try to play the song, I get an error message; "The song "_____" could not be used, because the original file could not be found. Would you like to locate it?"
    This began to happen when Chuck made playlists2burn on2CD-and then he would delete the playlist; sending all the song files into oblivion. Certain songs have a ! right next to the file name, and as I stated before, i get that error message:
    "The song "_____" could not be used, because the original file could not be found. Would you like to locate it?"
    So I click on "Locate". No help. I get a menu with folders that say "catroot" and other folders which names I cannot remember, but I scroll PAST the file folders, & it's just a bunch of ".DLL" files.....I don't understand what any of the names of the folders mean...it's frustr8ing-coz this is my 2nd iTouch, my 1st one got stolen & I can't afford2buy my music back at this time & i NEVER before had a single problem with losing song file locations.
                  Is there anyone out there who has been through this frustrating game of chasing your tail?....<that's how I feel>
    If so I would be ever so gr8ful if maybe someone with the knowledge would be so kind as 2 tell me how/where 2 retrieve these songs & how to put everything back where it belongs, I would be 4ever gr8ful !!!
    I can't afford 2 replace the songs just like I'm unable 2 buy back my old music from my stolen iTouch....man that was an awesome collection-someday I'll be able 2 afford 2 do that & I would like 2 have all the new music that I paid 4 but cannot find when I got my new iTouch....that would just be  wonderful.
                 I hope someone sees this post that can help me retrieve these files....losing $100.00 of iTunes is a REAL BUMMER!!!!!!
                                                      ThanQ SO very much!
                                                                             [email protected] or [email protected] or [email protected] .
                                                                                               You can also find me on Facebook, my given name is Tiffinie Trimmer, &
                                                                                                that's my Facebook "handle".    ThanQ 4 taking the time 2 read all of this!
                                                                                                hope 2 get a reply someday....I'll B checking all my emails & my Facebook, as well
                                                                                                as marking this page in my FAVORITES so I can find it fast! Take Care!!!

    I was not complete clear.
    Since you never changed the settings in the advanced section of iTunes preferecnes, you have to chech that your music is really in the location setted in the folders reported in the advanced section.  If not you have 2 ways: reset the position of this folders or in the actual disk organisation or in the pointing on the preferences.
    If you press the reset button you just give to itunes its default setting as for the position of the music files: probably this will be a good choice if you have never changed any default preference.
    But before I would check the folders and see if the songs are really there
    In my iTune I have this, and I believe it is the default.
    Users/YOURHOMEFOLDERNAME/Music/iTunes/iTunes Music

  • Some of the songs I have downloaded onto i tunes won't play when I select it to do so.  The error message I get is "The song could not be used because the original file could not be found.  Would you like to locate it?"  How can I get my songs to play?

    Some of the songs I have downloaded into i tunes won't play when I select it to do so.  The error message I get is "The song can not be used because the original file can not be found.  Would you like to locate it?"  When I select yes I'm sent to a screen that has my i tunes library listed.  When I select the song in question I'm asked if I would like to open the song.  When I select this option I get nothing.  The songs I have downloaded must be somewhere because they are listed in my i tunes library and on the screen I've been sent to.  I can't the songs to play however.  This is not true of all of my songs but it is true of quite a few of them.  Actually, one song is too many.    How do I get my music to play that seems to be locked up somewhere in the computer?

    Presuming they're on your computer, right click on them and then follow the prompts to locate hte file on your computer.

  • There are about 8 songs in a playlist on itunes that are listed in the playlist but cannot be transferred to my ipod because it states: "..the original file could not be found." When I try to locate the song I get a list of the different music librar

    There are about 8 songs on a playlist that are listed in the playlist library but when I try to transfer them to the playlist, it states that they can't be transferred because the original file could not be found. Then it asks, do you want to locate the file but when I try that I get a few libraries but am not sure how to locate the particular songs. Some of the songs were purchased and some were transferred from a CD. I have seen the same question asked on the help page but haven't found an answer.
    Thanks.

    Hi dones49,
    It sounds like your issue here is that iTunes can not find the files for some of the songs you have brought into it. This happens occasionally even if the songs have not been moved from the location that iTunes places them on import or purchase. When you try to use the song, iTunes prompts you to find the file, as you have seen.
    To find the file, use the information in this article to navigate through the iTunes media folders -
    Locate and organize your iTunes files
    If you are still unable to locate the files, you may need to download them from the iTunes store again, or rip them from your CDs. See this article for assistance with downloading your past purchases -
    Download past purchases
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • When using Iphoto to import photo from existing folder, what happens if I delete the photo in Iphoto ? Will the original file in the folder be deleted too?

    When using Iphoto to import photo from existing folder to iphoto, what happens if:
    1. I delete that photo in iphoto? will the original file in the folder be deleted too ?
    2.  when importing, does the hard disk store 2 versions of the photo, hence occupying additional space in the harddisk?

    1 - no  --  iPhoto only manages fiel within the iPhoto library - it does not ever do anything with files outside the library
    2 - No idea what you are asking - by default (and strongly recommended) iPhoto copies the original to the iPhoto library and you delete the source file outside the iPhoto library - iPhoto alwasy has at least two versions of every photo and some times three - it always have the original, a thumbnail and once a photo is modified a preview - this is not optional - if it is not what you want then iPhoto is not the correct progrtam to be using for phopto management
    LN

  • I recently reset my computer and copy my music from an external hard drive to my itunes library.  When I click on a song to play i get an error message that says " the song could not be used because the original file could not be found".  need help

    I recently reset my computer and copy my music from an external hard drive to my itunes library.  When I click on a song to play i get an error message that says " the song could not be used because the original file could not be found".  But when I have my external hard drive plug in the song will play with no problem.  What do I need to do to play my music without having the external harddrive plug in ????????  Please help

    Because the location for each song in your library is on your hard drive.  If the hard drive isn't there, how can iTunes play it?
    You'll have to move/copy the music from your hard drive to your computer's hard drive.
    Basically, EASIEST way to do all this, if you don't care about your play counts, etc...
    -Delete EVERYTHING from iTunes, so that your library is now empty.
    -Go to "Advanced" inside of the "Preferences" window, found in the "Edit" drop-down.  You can also access Preferences by pressing Ctrl+, (Press Ctrl and the comma key)
    -Change your iTunes Media Folder Location to something simple, but on your computer. I use C:/iTunes.  Make sure "Keep iTunes Media Folder Organized" and "Copy files to...." are both checked.  You can close Preferences now.
    -Now, drag and drop your music from your hard drive into your iTunes library.  iTunes will automatically add the music to your library, as you would expect, and also creates a copy of each file to place into that iTunes Media Folder you just created.
    Shouldn't have any more problems...

  • Error message when trying to play music on computer states The song ... could not be used because the original file could not be found.  However, my library shows how many items and the GBs used.  How do I locate the files?

    When I try to play my iTunes music on my computer, an error message comes up and state "The song (title of song) could not be used because the original file could not be found.  Would you like to locate it?
    When I click on Locate It, I cannot find where the music file may be located.  Does anyone have any suggestions?
    This all occurred when I attempted to do a backup to an external hard drive.  Unbeknownest to me, the files did not copy over and do not appear on the external hard drive. 
    When I open my iTunes library, at the bottom of my music list it shows how many songs and the GBs, so it appears that the files are still there; however, cannot be located.
    Thank you.

    Hi angela dfromtx,
    When tracks in iTunes display a it means the file cannot be located; it may have been moved or deleted. You'll have to locate the file manually if it is still available. For more information refer to the following article:
    iTunes: Finding lost media and downloads
    http://support.apple.com/kb/TS1408
    Alternatively, if your media was downloaded from the iTunes Store, you may be able to download it again free of charge:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/HT2519
    Thanks,
    Matt M.

  • I have a new hard drive as my old one crashed. Everything seemed to transfer fine except for my entire iTunes library. It shows all of my old songs, but when I click on one it states "the song could not be used as the original file could not be found

    I have a new hard drive as my old one crashed. Everything seemed to transfer fine except for my entire iTunes library. It shows all of my old songs, but when I click on one it states "the song could not be used as the original file could not be found.would you like to locate it".
    Either how do I locate it, and I've tried every trick I know, or how do I restore all of my songs from one of two sources. I have my old hard drive backedup on an external drive which should have all of my songs, and I have most of my songs on my old iPhone 3S which I'm using as a backup iPod.

    The "missing file" error happens if the file is no longer where iTunes expects to find it. Possible causes are that you or some third party tool has moved, renamed or deleted the file, one of its parent folders, or the drive it lives on has had a change of drive letter. It is also possible that iTunes has changed from expecting the files to be in the pre-iTunes 9 layout to post-iTunes 9 layout, or vice-versa, and so is looking in slightly the wrong place. In the case of a library moved from one system to another there are also potential permissions issues. See Repair security permissions for iTunes for Windows.
    Select a track with an exclamation mark, use Ctrl-I to Get Info, then click No when asked to try to locate the track. (Due to a bug in iTunes 12 you currently have to say No twice!) Look on the summary tab for the location that iTunes thinks the file should be. Now take a look around your hard drive(s). Hopefully you can locate the track in question. If a section of your library has simply been moved, a folder renamed, or a drive letter has changed, it should be possible to reverse the actions. If the difference between the two paths is an additional Music folder in one path then this is a layout issue. I can explain further if that is the case.
    In some cases iTunes may be able to repair itself if you go through the same steps with Get Info but this time click Locate and browse to the lost track. It may then offer to attempt to automatically fix other broken links.
    If another application like Windows Media Player has moved/renamed the files then the chances are that subtle differences in naming strategies will make it hard to restore the media to the precise path that iTunes is expecting. In such cases, as long as the missing files can be found somewhere, you should be able to use my FindTracks script to reconnect them to iTunes. See this post for an explanation of how it works.
    See also Recover your iTunes library from your iPod or iOS device.
    tt2

  • I have movies in my movie library but i cannot play them or drag them into my ipod.There is an exclamation point next to each of them.Then when i click on it to play it it says the movie cannot be used because the original file could not be found.

    I have movies in my i tunes library but i canot play them or drag them into my i pod.There is an exclamation point each of them.Then when i click on them to play them on my pc it says this movie cannot be used because the original file could not be found.Help?

    Read threads list over on the right under the heading of More Like This
    Allan

  • I can't listen to at least 100 of my songs on itunes. When I try it gives me a message that it can't play that song because the original file could not be found. Would you like to locate it? What do I do?

    When I try to listen to certain songs a message pops up that the original file could not be found. Do you want to locate file? I don't know how this happened and I don't know what to do. I have tried repairing Itunes and also uninstallng and reinstalling. I have restarted my computer and even done some troubleshooting. When I tried hooking my ipod up to my computer to see if that would help I got a message that said "At least 100 songs could not be transferred, including "You found me."" I have no such song in my itunes. Can itunes get a virus?
    Does anyone have any ideas what I can do? I'm at a loss and would really like my itunes to be back to normal.

    I was not complete clear.
    Since you never changed the settings in the advanced section of iTunes preferecnes, you have to chech that your music is really in the location setted in the folders reported in the advanced section.  If not you have 2 ways: reset the position of this folders or in the actual disk organisation or in the pointing on the preferences.
    If you press the reset button you just give to itunes its default setting as for the position of the music files: probably this will be a good choice if you have never changed any default preference.
    But before I would check the folders and see if the songs are really there
    In my iTune I have this, and I believe it is the default.
    Users/YOURHOMEFOLDERNAME/Music/iTunes/iTunes Music

  • When importing a cd on to itunes where is the original file kept because my itunes folder doesn't have it, the song does come up when i spotlight search it but i can't locate it

    i cannot seem to find where the original file for tracks that have been imported from a cd are kept because they are not in the itunes folder, however the song is somewhere as it does show up on spotlight search and plays when i click it. where would i find it?!

    It will be in the iTunes media folder location shown in iTunes prefs > Advanced.
    Select the song, right click > Show file in Finder.

  • Recently bought  a new computer and all my music appears in iTunes as well as on my computer in a saved folder. When I try to play the music in iTunes I get an error that reads"the song could not be used because the original file could not be found."

    Recently bought  a new computer and all my music appears in iTunes as well as on my computer in a saved folder. When I try to play the music in iTunes I get an error that reads"the song could not be used because the original file could not be found. Would you like to locate it?" Hope you can help me solve this issue.
    Thanks,
    Shellyboo

    This happens if the file is no longer where iTunes expects to find it. Possible causes are that you or some third party tool has moved, renamed or deleted the file, or that the drive it lives on has had a change of drive letter. It is also possible that iTunes has changed from expecting the files to be in the pre-iTunes 9 layout to post-iTunes 9 layout, or vice-versa, and so is looking in slightly the wrong place.
    Select a track with an exclamation mark, use Ctrl-I to get info, then cancel when asked to try to locate the track. Look on the summary tab for the location that iTunes thinks the file should be. Now take a look around your hard drive(s). Hopefully you can locate the track in question. If a section of your library has simply been moved, or a drive letter has changed, it should be possible to reverse the actions.
    Alternatively, as long as you can find a location holding the missing files, then you should be able to use my FindTracks script to reconnect them to iTunes .
    tt2

  • I recently restored my laptop and also iTunes from an external hard drive, but when I play songs, it says the original file could not be found. How do I locate and fix this?

    I recently restored my laptop with Windows 7 and imported my iTunes library from my external hard drive. When I try to play songs, it says it cannot and that the original file could not be located. How do I fix this?

    Put the files back where iTunes expects them to be.

  • When trying to sync or listen to songs in itunes library it says the song on itunes could not be used because the original file could not be found. I am using windows 7.

    I have imported cds into my itunes and they appear on my playlist, but when I try to sync to my ipod or listen to them on my computer a message comes up stateing " the songs on itunes could not be used because the original file could not be found".  I have not deleted them and am importing them the way I always have.  This problem has only been for the last 4 or 5 months. Since updating to the last 2 itunes versions.

    The message means that iTunes can not find the original imported music files. iTunes should display a red exclamation mark next to the songs it can not find. You will need to look on your hard drive for the songs/files and than correct the file path in iTunes or just delete the files in your iTunes library and import them again.

Maybe you are looking for