Compare number of items in two folders then move an item if same number

Hello,
I've succesfully created a Folder Action with Automator that once an image file is dropped into a folder called "Funnel", that file will run through some Photoshop processing and then be saved in two different formats in two respective folders (let's call the two folders "A" and "B").
The problem that I'm running into is that I can't drop a bunch of files into the "Funnel" folder at once because it will bog down Photoshop. My solution to this is to create a folder called "Waiting Room" where I will dump a large amount of files. I'm trying to write a Folder Action/AppleScript that will recognize when a file (or files) have been dropped into "Waiting Room", it will then look at the number of items in folders "A" and "B" and if the numbers are the same, that means that Photoshop is done processing the last image it worked on and is free for more work. If that's the case, it will move the last item in the "Waiting Room" to "Funnel" which will then process the file. Because Photoshop will save one format to folder "A" before it saves another format to folder "B" the two folders wont have the same number of items and "Waiting Room" will not be able to transfer another file to "B" until both folders have the same number of items again. This should force it so that Photoshop is only receiving one image file at a time to process.
This is what I've done so far and it isn't working.
I get the following error:
Please help! I'm pretty new to all of this and am guessing at the AppleScript stuff. Thank you!!!

Thank you so much Niel! I no longer get the error. The only thing is, it only processes one file and then the rest of the files just sit in the "Waiting Room" folder. I thought that writing 'return 30' would make the script check folders "A" and "B" every 30 seconds, esentially looping the script, but it isn't working. Thoughts?
Also, keep in mind that there is a short moment where the last file in "Waiting Room" has been passed to the "Funnel" folder and photoshop is doing it's thing and is about to save a version of that file in folder "A". So although Photoshop is currently busy, folders "A" and "B" still have the same quantity, so the script may want to throw a bunch of files into "Funnel" rapidly until Photoshop finally saves something in "A" and it no longer matches the quantity in "B". That's why I thought a 30 second buffer might be a good idea.
Thanks again for taking the time. Cheers!

Similar Messages

  • Comparing files in two folders to find duplicates using part of file name

    I'm not sure if this is something Automator or perhaps Terminal can do, hoping someone might be able to offer guidance or suggestions.
    I have two folders filled with files of photographs.
    First folder has approx 15,000 files.
    Second folder has approx 1,200 files.
    I need to compare the files in the two folders and remove duplicates from the First folder. In other words, the 1,200 files in the Second folder are also in the First folder and they need to be removed from the First folder, leaving 15,000 - 1,200 = 13,800 files in the First folder.
    To add a wrinkle to the comparison (nothing is ever that easy), the file names are consistent between folders for the first 17 characters (files follow the format of my name_6 digit date_4 digit # sequence, ie nickB0904087110.jpg) but in the Second folder, the files will have an additional tag added to the file name (ie nickB090408_7110Final.jpg).
    Any suggestions or help much appreciated!
    nick

    Old post, sorry, but for the sake of trying to answer it:
    The method described here can accomplish the goal, as I understand it.
    http://texo.wordpress.com/2009/08/17/comparing-large-directories-fast-in-osx-or- linux/
    rsync -rvn --delete /FirstDirectory /SecondDirectory
    (He describes: The 'n' flag is a 'dry-run'; remove it and the files will be copied. And '--delete' deletes any files NOT in the FirstDirectory.)
    I found I needed to put slashes at the end of the directory name too. ... /Directory1/ /Directory2/
    That way it seems to compare those actual folders. Without the slashes, it just put a copy of Directory1 into Directory2. I'm sure there's something I don't understand about rsync though.

  • Comparing contents of two folders

    Is there a way to compare the files in two folders--a folder on my machine and a folder on a removable storage device such as a PC card--and output the names of the files that are missing from the folder on my machine?
    My machine often drops files unexpectedly when I copy them from my PC card to hard drive and I want to be able to then find the 2 or 3 missing files (out of 500-800 images which I have copied) quickly.
    Thanks.
    Pedro Paramo

    'Is there a way to compare the files in two folder ...' - Yes.
    '... a folder on my machine and a folder on a removable storage device such as a PC card ...' - I have no idea what a PC card is (with exception to the former PCMCI card - renamed PC Card. Please do not explain). Perhaps you mean an external storage device - like a USB 'thumb' drive, etc.
    'My machine often drops files unexpectedly when I copy them from my PC card to hard drive' - Welcome to MacOS X.
    Sample source code:
    property destFolder : ((((path to desktop folder from user domain) as string) & "Destination Folder:") as alias) -- Provide the appropriate full path to the destination folder.
    property srcFolder : "Source Folder" -- Provide the name of the source Folder.
    on run -- Exectued if user double clicks on applet. Display an appropriate message.
    display dialog "Drag USB 'thumb' drive(s) onto this applet, for further processing." buttons {"OK"} default button 1 giving up after 5
    eproperty destFolder : "Destination Folder2" -- Provide the appropriate full path to the destination folder.
    property srcFolder : "Source Folder" -- Provide the name of the source Folder.
    property destPath : ((((path to desktop folder from user domain) as string) & destFolder) as alias) -- Your full path to your 'destFolder' may vary. If so, edit this line accordingly.
    on run -- Exectued if user double clicks on applet. Display an appropriate message.
    display dialog "Drag USB 'thumb' drive(s) onto this applet, for further processing." buttons {"OK"} default button 1 giving up after 5
    end run
    on open (dItems) -- Executed if user drags an item or items onto the applet.
    my process_Items(dItems) -- Process dragged on items.
    end open
    on process_Items(tItems)
    tell application "Finder"
    try -- Capture any AppleScript created error(s).
    set destItems to displayed name of every file of destPath -- Names of files in 'destFolder'.
    on error
    set destItems to {} -- Set 'destItems' to empty list, if 'destPath' is empty.
    end try
    repeat with i in tItems
    if ((kind of i) is "Volume") then -- Limit 'kind' of items to process.
    set srcItems to (every file of (((i as string) & srcFolder) as alias)) -- Names of files in 'i's (an individual volume) 'srcFolder'.
    repeat with j in srcItems -- Cycle through list of files in 'srcFolder'.
    try -- Capture any AppleScript created error(s).
    if (not (destItems contains (displayed name of j))) then duplicate j to destPath -- Duplicate files in 'srcFolder' not in 'destFolder'.
    on error
    if (destItems is {}) then duplicate j to destFolder -- Duplicate files in 'srcFolder' not in 'destFolder'.
    end try
    end repeat
    end if
    end repeat
    end tell
    end process_Items
    Save the above code as an 'Application' (AppleScript applet).
    Drag any volume or volumes onto the applet for processing.

  • How can i compare the contents of two folders ?

    how can i compare the contents of two folders and find out which files are in one but not in the other?? Knowing how to do this would be the best thing ever, especially when dealing with a large number of files. Often, for instance, I'm dealing with a large number of images, processing them, and saving the retouched ones to a new folder, and need to check that they are all there. If there are say three files missing in the second folder (out of say a hundred in total) being able to automate the process of elimination would be very useful. Please help!!!
    B

    I really wish I knew the answer to this. I work between two macs, a G5 and MacBook Pro when I'm on the go. Each time I move from one to the other I have to copy all my files to the computer I'm going to work on, so I end up with the same files being duplicated. It's not a problem if it's not much data but in my case the it can be to 30GB, mostly graphics files, photoshop, motion, final cut pro, etc.
    There's has got to be a way automator can make a comparison between two folders to sort out what's changed and what's remained the same. It would be nice also if this feature could be done globally on the hard disk using spotlight's technology to stop files being duplicated in places you didn't even know about and taking up valuable disk space. I'm not sure how this could be done.
    Any bright ideas Apple?

  • I downloaded the latest operating system for my iPhone 5.  It worked fine for about two minutes then the phone requested a password number to continue. Each time I inserted numbers, the phone would lock up for a period of time.  Now, it says "iPhone

    I downloaded the latest operating system for my iPhone 5.  It worked fine for about two minutes then the phone requested a password number to continue. Each time I inserted numbers, which were incorrect, the phone would lock up for a certain period of time.  Now, it says “iPhone is Disabled”.  It said to “Connect to iTunes” which I did, but iTunes does not recognize my phone.  If I scroll the face to the right, it goes to the phone number face and says, "No Service". Can I do something to make the phone work?

    Forgot passcode for your iPhone, iPad, or iPod touch, or ...

  • I've downloaded a language course on to my iMac.  It is in two folders on the desktop.   There is no corresponding app, so how can I transfer it to the iPad ?

    I've downloaded a language course on to my iMac  - where it sits on the desktop in two folders.    I want to transfer it to the iPad, but syncing doesn't work when I click the folder and then the sync button.     There is no app for this particular course.    The audio consists of a number of MP3 files.   How can I make it useable on the iPad ??

    Launch iTunes on your computer and from the menu at the top go to File>Add to Library and then navigate to wherever the files are located on your desktop. Create a playlist in iTunes if you want to and then sync the playlist to the iPad. Play the files in the Music App on the iPad.

  • Compare sales order items (specific fields)

    Hi guys,
    I need to compare some fields from vbap and vbkd and to add values from sales order items, before I print then on screen.
    I need to compare if vbkd-ihrez_e and vbkd-bstkd and vbap-matnr are the same for two records from sales order (10 and 20), If they are the same then add vbkd-ihrez values (for items 10 and 20), also add vbap-kwmeng, and write that sum on screen.
    Compare item with previous one. if doing for 20 compare with 10, for item 30 compare with 20 etc.
    I start like this.
    select aubel posnr into (wa_tab-vbeln, wa_tab-posnr)
             from vbrp
             where vbeln = p_vbeln.
        append wa_tab to it_tab.
      endselect.
    loop at it_tab into wa_tab.                   << I need somewhere to compare fields if they are the same before I print them.
          select single fbuda bstkd_e ihrez_e ihrez bstkd
                          into
                          (wa_tab-fbuda,
                          wa_tab-bstkd_e,
                          wa_tab-ihrez_e,
                          wa_tab-ihrez,
                          wa_tab-bstkd)
                          from vbkd
                          where vbeln = wa_tab-vbeln and
                                posnr = wa_tab-posnr.
    select single kbmeng waerk netwr arktx kwmeng
                          into
                          (wa_tab-kbmeng,
                          wa_tab-waerk,
                          wa_tab-netwr,
                          wa_tab-arktx,
                          wa_tab-kwmeng)
                          from vbap
                          where vbeln = wa_tab-vbeln and
                                posnr = wa_tab-posnr.
    modify it_tab from wa_tab.
    endloop.
    How can I modify code to get this process? Thanks,
    Edited by: nihad omerbegovic on Nov 2, 2009 9:45 AM

    Hi Nihad
    select aubel posnr into CORRESPONDING FIELDS OF TABLE it_tab
    from vbrp
    where vbeln EQ p_vbeln.
    select a~vbeln a~posnr a~fbuda a~bstkd_e a~ihrez_e a~ihrez a~bstkd
    b~kbmeng b~waerk b~netwr b~arktx b~kwmeng
    into CORRESPONDING FIELDS OF TABLE it_vb
    from vbkd as a INNER JOIN vbap as b ON a~vbeln EQ b~vbeln AND a~posnr EQ b~posnr
    FOR ALL ENTRIES IN it_tab
    where vbeln EQ it_tan-vbeln and
    posnr EQ it_tab-posnr.
    SORT it_tab BY vbeln posnr.
    LOOP AT it_tab INTO wa_tab.
    IF lv_vbeln EQ wa_tab-vbeln. "means it's the same order but a different item
    IF ( lv_ihrez_e = wa_tab-ihrez_e ) AND ( lv_bstkd = wa_tab-bstkd ) AND ( lv_matnr = wa_tab-matnr ).
    ADD wa_tab-kwmeng TO lv_kwmeng.
    WRITE lv_kwmeng.
    ENDIF.
    CLEAR lv_kwmeng.
    lv_ihrez_e = wa_tab-ihrez_e.
    lv_bstkd = wa_tab-bstkd.
    lv_matnr = wa_tab-matnr.
    lv_vbeln = wa_tab-vbeln.
    lv_kwmeng = wa_tab-kwmeng.
    endloop.
    Thanks
    Pushpraj

  • I downloaded Lion on my iMac (i7 mid 2010) and my Apple applications show up in the first Launchpad screens in two folders labeled as "Utilities". What's up? How can I correct this? At first, I didn't think the applications were there.

    I downloaded Lion on my iMac (i7 mid 2010) and my Apple applications show up in the first Launchpad screen in two folders titled "Utilities". How can I fix this? At first I didn't think they were there.

    Click the Utilities icon/folder to see the contents and then drag the items out of the folder upwards onto the Desktop and they will be removed from the folder.

  • How can i delete photos in a folder from my Iphone 4s.  when it was synced, the photos went to two folders and not to the camera roll

    How can I delter photos in a folder from my Iphone 4s?  When I synced the new phone from the Itunes, the photos went to two folders and not the camera roll. 

    thanks, should I delete all the phones on Itunes and re sync the old phone, then resync the new phone to get the pictures?  Will they go to camera roll instead of a folder?

  • Sharing two folders with the same name

    Hi all.
    I have two folders with the same name and I would like to be able to share these under different share names. Problem is, this doesn't seem to be possible.
    For instance, try doing this in File Sharing under Server Preferences:
    * Click +, add /Data/Media
    * Edit permissions on "Media" to permit guest access
    * Click +, add /Volumes/Drobo/Media
    * Edit permissions on "Media" (make sure you click the right one!) to permit guess access.
    This appears on the surface to work, but what it has actually done is to delete the share for /Data/Media. If you exit the File Sharing pane and go back into it again, it will be gone.
    Server Admin has the ability to rename a share's name from AFP,SMB,FTP,etc. but this doesn't appear to help either -- I tried adding the second media first, renaming its shared name to Media2 over in Server Admin, and then adding the first. Server Preferences just deletes the second one.
    Such a basic thing as being able to rename the share from Server Preferences would appear to be enough to get around this, but since Apple didn't make it possible, I have no idea how to proceed.
    Does anyone else have this working, and how did you do it?

    The best way to solve this, would be make sure you use database paraneter GLOBAL_NAME, to change your database from lets say orcl1 to orcl1.mycorpdomain.com, by this you can make sure each database actualy has a different name. Your other database then could be named orcl1.example.com.
    When chaning the display name in EM you might face other issues later on when for instance trying to run a restore using EM for one of these databases.
    Regards
    Rob
    http://oemgc.wordpress.com

  • One account with two folders on the hard drive

    Sorry but i think this is a very basic question.
    I have one user (the administrator), but on the hard drive there are two folders. One named Peter and the other named Dad. I have all of my files in the folder named Peter. I seem to be logged in to the Dad folder. The desktop has nothing on it but in the Peter folder there are many items. Same with the music folder, and there is nothing in iTunes.
    Thanks
    Mac mini   Mac OS X (10.4.7)  

    Check to see whether your account is listed as the owner of both folders in the Ownership & Permissions section of the Get Info window, which is available by control-clicking the folder; if so, open the NetInfo Manager in the /Applications/Utilities/ folder, click the padlock, and type in your password. Next, locate the home property for your user account and change the instance of Dad to Peter in it without changing or deleting any other accounts, groups, or properties. Log out and log back in.
    The contents of the Users folder do not indicate which accounts are present on the machine; this folder is the default location for the home folders associated with accounts you've created. It is possible to have a folder inside Users without a corresponding account, and you can have an account on the machine without its home folder being in Users; this applies to system-level accounts by default, but you can set it up for your account or other accounts you've created in the NetInfo Manager.
    (15829)

  • Hi, I have small problem, for some time in music area I had two folders to use 1. Apple loops for soundtrack pro 2. Final Cut pro sound effects now both are gray and with out content may I know what happend

    Hi, I have small problem, for some time in music area I had two folders to use 1. Apple loops for soundtrack pro 2. Final Cut pro sound effects now both are gray and with out content may I know what happend

    I just went through this and it appears that my Focusrite Saffire was the culprit. I connected all the outputs on the focusrite according to the way the jacsk on the back were labeled and then set up the multichannel speaker setup to match. Then I went into STP, created a pink noise clip and panned it around, the LFE, center and rears were not in the right place.
    I reconnected the hardware to match the 5.1 pan pot in STP then changed the multichannel speaker setup to match. Everything appears to be correct now but I would have loved to have been able to just assigned the output busses to correct outputs in the saffire.
    Next step is to pan that pink noise around with my SPL meter to calibrate the room.

  • I organized all my files into folders then went to organize them and now all the folder contents are stacked on top of the folders on the desktop. How do I fix it?

    I Spent hours organize items into individual folders, then thought I hit arrange by name but now all the contents of the folders are on my desktop on top of the folders they were in...how can I get the contents back in the folders?

    Have you looked at the previous discussions listed on the right side of this page under the heading "More Like This"?

  • Comparing the creation time of two jars.

    Hi,
    My requirement is that i need to compare the creation time of two of the jars and see which one of the jar is the latest.
    I did it using the following code i get the output in the form of strings so i cant compare them to find which one is the latest.
    import java.io.*;
    import java.util.*;
    public class FileTest {
         public static void main(String args[]) {
              File devbuild = new File(
                        "\\\\devspace\\dev$\\ReleaseEng\\DEVbuilds\\tw_enterprise\\build\\jboss\\Oracle\\Twelibrary.jar");
              File local = new File(
                        "D:\\jboss-4.2.1.GA\\server\\TWEServer\\Twelibrary.jar");
              Calendar now = Calendar.getInstance();
              int currtime = now.get(Calendar.HOUR_OF_DAY);
              int maxtime = 18;
              System.out.println("Before the while loop");
              while (currtime < maxtime) {
                   System.out.println("Inside the while loop");
                   if (devbuild.exists()) {
                        try {
                             // get runtime environment and execute child process
                             Runtime systemShell = Runtime.getRuntime();
                             BufferedReader br1 = new BufferedReader(
                                       new InputStreamReader(new FileInputStream(devbuild)));
                             BufferedReader br2 = new BufferedReader(
                                       new InputStreamReader(new FileInputStream(local)));
                             Process output = systemShell.exec("cmd /c dir " + devbuild);
                             Process output1 = systemShell.exec("cmd /c dir " + local);
                             // open reader to get output from process
                             BufferedReader br = new BufferedReader(
                                       new InputStreamReader(output.getInputStream()));
                             BufferedReader br3 = new BufferedReader(
                                       new InputStreamReader(output1.getInputStream()));
                             String out = "";
                             String out1 = "";
                             String line = null;
                             String line1 = null;
                             int step = 1;
                             int step1 = 2;
                             while ((line = br.readLine()) != null) {
                                  if (step == 6) {
                                       out = line;
                                  step++;
                             } // display process output
                             while ((line1 = br3.readLine()) != null) {
                                  if (step1 == 6) {
                                       out1 = line1;
                                  step1++;
                             try {
                                  out = out.replaceAll(" ", "");
                                  out1 = out1.replaceAll(" ", "");
                                  System.out.println("CreationDate: "
                                            + out.substring(0, 10));
                                  System.out.println("CreationTime: "
                                            + out.substring(10, 16) + "m");
                                  System.out.println("CreationDate: "
                                            + out1.substring(0, 10));
                                  System.out.println("CreationTime: "
                                            + out1.substring(10, 16) + "m");
                             } catch (StringIndexOutOfBoundsException se) {
                                  System.out.println("File not found");
                             //Long modifiedtime = devbuild.lastModified();
                             //long oldtime = old.lastModified();
                             int devbuilddate = Integer.parseInt(out.substring(0, 10));
                             int devbuildtime = Integer.parseInt(out.substring(10, 16));
                             int localbuilddate = Integer.parseInt(out1.substring(0, 10));
                             int localbuildtime = Integer.parseInt(out1.substring(10, 16));
                             if (devbuilddate >= localbuilddate && devbuildtime >= localbuildtime) {
                                  System.out.println("The Build date is Later than the one i am having--->");
                                  System.exit(6);
                             } else {
                                  System.exit(0);
                        } catch (Exception e) {
                             e.printStackTrace();
                   if (currtime > maxtime) {
                        System.exit(5);
    How can i do it?
    Can anyone help me out in this.
    Thanks,
    Kavipriya.

    Hi Clap,
    Thanks for ur reply. Let me say you the scenario clearly. We are in the process of automating some of the process. We have builds running daily night and our automation will run using that build.
    Currently the build which is getting generated does have manifest in it. For our automation framework we cant suggest adding the manifest. Which will not be agreed.
    Our automation will be checking till 10.am. to check whether the build is ready if not it will come out of the loop. If the build is avaialble within 10 then it will take the build and see whetehr the creation date and time of the build and the one i am having locally or different. If diff it will see whether the build generated is latest than the one i am having.
    If it so then the process will run.
    So hope you got my issue.

  • (cross post) Batch of two folders in...

    I have two folders with image sequences. I would like to run a batch of some sort, which opens one file from each folder, copies one of the images into a new layer of the other, then saves the results to a new folder, and continues.
    Is this possible? How?
    ty
    p.s. I am on Mac OSX Lion 10.7.2 with CS5

    C. thanks again.
    I found I can place the .jsx file into that scripts folder on my disk and then use "File > Scripts > Browse" to run it.
    However, one image sequence is .png and the other is .tif, so will have to add some code, which I think I can do, to fix it.
    Cheers
    William
    #target photoshop
    var inputFolderA = Folder.selectDialog("Please select ImageA folder");  
    var inputFolderB = Folder.selectDialog("Please select ImageB folder");  
    var outputFolderE = Folder.selectDialog("Please select output Folder ImageE folder"); 
    var fileList = inputFolderA.getFiles ("*.png");
    var startRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.PIXELS;
    for (var a = 0;a<fileList.length;a++){
              var file =fileList[a];
              var fileB = file.name.replace(/A/,"B");
              fileB = file.name.replace(/png/,"tif");
              var doc = open(file);
              var Bimage = File(inputFolderB +"/" + fileB);
              if(Bimage.exists) {
                 var b = open(Bimage);
                 activeDocument.selection.selectAll();
                 activeDocument.selection.copy();
                 app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                 activeDocument.paste();
              var saveFile = File(outputFolderE +"/" +file.name.replace(/A/,"E"));
              SavePSD(saveFile);
              app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    app.preferences.rulerUnits = startRulerUnits;
    function SavePSD(saveFile){
    psdSaveOptions = new PhotoshopSaveOptions();
    psdSaveOptions.embedColorProfile = true;
    psdSaveOptions.alphaChannels = true; 
    activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);

Maybe you are looking for

  • SQL Developer locks after splash screen

    I have succesfully installed SQL Developer on 2 machines in our group and it works fine. However on the machine where we really need it (mine) it absolutely refuses to work. It appears to start up, the splash screen appears and the sqldeveloper.exe a

  • Who kills your iPod after the installation of iPod updater?

    Hello all, First, sorry for my poor English. I am not a professional nor a technician and I could be wrong, so please correct me. There are many problems reported mainly from the PC users that their iPod can't be recognized nor mounted after the inst

  • ICloud Mail: Alias cannot be saved

    When I logged in on iCloud.com (also on my iPod Touch) my mail aliases have been disappeared! And that happens now that I wanted to switch to iCloud as mail service. Then I tried to create a new one, doesn't matter what I fill in, what label color I

  • Attachment  Document data from LEAD

    Hi Experts, I'm creating LEAD with attachment douments in it. Now I want to access the attachment document related data from that LEAD . How Do I need proceed ? Do we have some standard Function Module to do that ?

  • Changing Organization level for derived roles

    Dear All, Below is my query: When there is any requirement to change the organization level of a derived role, we go to the role and change the organization level manually. We have derived our roles, based on the units(company codes). Now we have a s