Copying new files to another folder with Folder Action?

Discussion in 'OS X' started by Evangelion, Nov 19, 2009.

  1. macrumors 68040

    Joined:
    Jan 10, 2005
    #1
    Is there a way to create a folder-action that accomplishes what I'm about to describe?

    I have iTunes-library (like most of us do). What I would like to accomplish is to copy my library to a server on my network. Of course I can do the initial copying manually, but what I would like to do is that whenever I add content to my library, a folder action kicks in, and copies that new content to the server.

    Now, I created a folder action with Automator, and it kinda works. What it does is that it looks at certain folder, gets folder-contents (subfolders included, since iTunes-library resides in subfolders), and copies them to another folder. It works, but what happens is that it copies the subfolders and their contents AND the individual files separately. I mean that if I copy a folder called XXXX which contains subfolders called ZZZZ and YYYY, which in turn contain files ABCD and 1234, it doesn't copy the folder XXXX, but it does copy the subfolders ZZZZ and YYYY and their contents. All well? Well, no, since it also copies the individual files (ABCD and 1234) to the root of the destination-folder. What I would like to copy the folders in similar way they are in the original folder.

    Also, what happens when I reboot my computer? When I log back in, would the folder copy the entire folder-structure all over again? I mean, I log in, the folder-actions runs, and copies the contents of the folder. What I would like it to do is to only copy files over when new files/folders are added.

    Any advice is welcome :)
     
  2. macrumors G3

    roadbloc

    Joined:
    Aug 24, 2009
    Location:
    UK
    #2
    I second this. I have been attempting to see if it can be done without 3rd party apps for a while now.
     
  3. thread starter macrumors 68040

    Joined:
    Jan 10, 2005
    #3
    Alternatively, instead of copying the entire folder-structure, the script could ignore the folders, and just copy actual files contained in those folders. That would work as well. Of course it would have to monitor all the folders and subfolders for new files.
     
  4. macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
  5. thread starter macrumors 68040

    Joined:
    Jan 10, 2005
    #5
    That just might do it, thanks :). I just have to make sure that I can make it sync in one direction only.
     
  6. thread starter macrumors 68040

    Joined:
    Jan 10, 2005
    #6
    I'm testing SyncTwoFolders, and I don't think it's the solution I'm looking for. The files are supposed to be copied to "Automatically add to iTunes"-folder. When files are added there, they are imported to iTunes and moved to the iTunes library-folder. So the target-folder will always be empty.

    Now, the problem with SyncTwoFolders is that it will copy all files not present on the target-folder from the source-folder. And since the target-folder will always be empty, ti would copy the files over and over again.

    Also, how would I make SyncTwoFolders run every time new files are added to the folder?

    So, I'm still looking. Any suggestions?
     
  7. thread starter macrumors 68040

    Joined:
    Jan 10, 2005
    #7
    I have managed to take one step closer to the solution, but I'm stuck again.

    My original solution was a Automator-script that gets folder content from the source-folder and copies that content over to the target-folder. But the problem was that it copied the files AND the folders (so the coped content was multiplied).

    What I did was that I added a third step to the workflow (between "get folder contents" and "copy Finder items"): "Filter Finder items". That step just contains a "kind is not folder"-filter (so that it does not select them for copying). And it does seem to work, since it only copies the contents of folders and subfolders, but not the actual folders.

    But there is a problem. If I add a song to that subfolder, that song is NOT copied over. If I copy it to the root of the folder, then it works. I have selected the "repeat for each subfolder found" in the first step of the Automator-script, but it doesn't seem to help. So it seems that the script only monitors the root-folder. If I add a file or subfolder to the root of the folder, the script works beautifully. But if I add a file to an existing subfolder (for example, download a new podcast episode to a show I subscribe to, or buy more songs from an artist who already has other songs in my library) the script does not run.

    Am I at the end of the line as far as Automator is concerned? Is AppleScript the next step?

    EDIT: If I add "Get specified Finder items" as the first step in Automator, and add the test-folder there, then the script works beautifully inside Automator. But if I save that workflow as a Folder Action, it does not work.

    EDIT2: I think this thread should be moved to the programming-forum, since this is about scripiting....
     

Share This Page