Help with Difficult Sorting Task - Script Inside

Hello,
I have a very time consuming task that I would like to adjust the script below to help cut down the labor. The script below, will ask for a root folder and will copy all the folders inside that root folder to a secondary location. It will only copy the folders and not the files inside them. This works great. But my next step is to manually drag and drop the ".cos" files from the "master drive" from each shot folder to the emtpy "Settings50" folder that has been duplicated to my desktop. Is it possible in any way, to first copy the whole folder structure, and then only copy the "Settings50" folder and the files inside them to the secondary location? The image attached shows what I need duplicated in green and what I do not want duplicated in red. The reason I cannot simply copy the whole root folder is because the RAW files in red are very very large and takes forever to copy. I ONLY need the folder structure duplicated with the Settings50 folder copied with files inside them to a secondary location. If you can help out I would very very much apprecieate it!
on run
          set source_folder to choose folder with prompt "Select folder to be duplicated:" as string
          my do_main_script(source_folder)
end run
on open of source_folder_list
          repeat with i from 1 to number of items in the source_folder_list
                    set this_folder_path to item i of the source_folder_list as string
                    if last character of this_folder_path is ":" then
                              my do_main_script(this_folder_path)
                    end if
          end repeat
end open
on do_main_script(source_folder)
          tell application "Finder" to set source_folder to folder (source_folder)
          set the target_folder to (choose folder with prompt "Where would you like the duplicated folders to be moved to?")
          if source_folder is not "" and target_folder is not "" then
                    set new_folder_name to (name of source_folder as string) & " duplicate"
                    set source_folder to source_folder as string
                    set target_folder to target_folder as string
                    my create_new_folder(target_folder, new_folder_name)
                    my duplicate_folder_structure(source_folder, target_folder & new_folder_name & ":")
          end if
end do_main_script
on duplicate_folder_structure(source_folder, target_folder)
          tell application "Finder"
                    try
                              get name of folders of folder (source_folder)
                              set folder_list to result
                              repeat with i from 1 to number of items in the folder_list
                                        set this_folder_name to item i of the folder_list as string
                                        my create_new_folder(target_folder, this_folder_name)
                                        my duplicate_folder_structure(source_folder & this_folder_name & ":", target_folder & this_folder_name & ":")
                              end repeat
                    end try
          end tell
end duplicate_folder_structure
on create_new_folder(target_folder, new_folder_name)
          tell application "Finder"
                    try
                              if not (exists item (target_folder & new_folder_name)) then
  make new folder at folder target_folder with properties {name:new_folder_name}
                              end if
                    end try
          end tell
end create_new_folder
Thanks!
Anthony

Well, I think this will be close.  test it and see what needs to be improved.
on run
          set source_folder to choose folder with prompt "Select folder to be duplicated:" as string
          my do_main_script(source_folder)
end run
on open of source_folder_list
          repeat with this_item in the source_folder_list
                    if last character of (this_item as string) is ":" then
                              my do_main_script(this_item as string)
                    end if
          end repeat
end open
on do_main_script(source_folder)
          set the target_folder to (choose folder with prompt "Where would you like the duplicated folders to be moved to?")
          if source_folder is not "" and target_folder is not "" then
                    tell application "System Events" to set new_folder_name to (name of source_folder) & " duplicate"
                    set new_folder to checkForFolder(target_folder as string, new_folder_name)
  duplicate_folder_structure(source_folder as string, new_folder)
          end if
end do_main_script
on duplicate_folder_structure(source_folder, target_folder)
          tell application "System Events"
                    set folder_list to folders of folder source_folder
                    repeat with this_folder in the folder_list
                              set this_folder_name to name of this_folder
                              set new_folder to my checkForFolder(target_folder as string, this_folder_name)
                              my duplicate_folder_structure(path of this_folder, new_folder)
                    end repeat
          end tell
          tell application "Finder"
                    set cos_file_list to every file of folder source_folder whose name ends with ".cos"
  duplicate cos_file_list to target_folder
          end tell
end duplicate_folder_structure
to checkForFolder(fParent, fName)
          tell application "System Events"
                    if not (exists folder fName of folder fParent) then
                              set output to path of (make new folder at end of folder fParent with properties {name:fName})
                    else
                              set output to (path of (folder fName of folder fParent))
                    end if
          end tell
          return alias output
end checkForFolder

Similar Messages

  • Anyone here can help with a quick bash script?

    I am no coder, by any means, unless you consider html code....I don't
    any how, here's what i'm trying to do, if someone who knows bash would like to assist?
    i have a folder, with a bunch of subfolders, inside these subfolders, is a setup.xml file.
    and inside these setup xml files is a line titled product code with a string after it.
    i could really use a script or sorts to go through and output all those product codes into a single text file right now, otherwise i'm sure i'll be here for hours
    anyone care to help?

    ooooh.......that works
    tweaked it a bit and ran it from the source folder, worked well, this is what i ran though
    find -name \Setup.xml -exec grep 'productcode' '{}' \; > theFile
    does this give you any idea as to the file structure of the xmls?
    <Setups productcode="ICA.productcode">
    <Msi productcode="UpdateX3.exe" file="WPO15\UpdateX3.exe" cmdline="/s" adminsupport="0" condition="UpdateX3=1"/>
    <Msi productcode="{6E274E81-F9E1-43A2-9672-E45F655953FA}" file="WPO15\UpgradesX4.msi" cmdline="ADDLOCAL=ALL" progresstext="Str.UpgradeProgressText" adminsupport="0" condition="REMOVE_14" scheduled="0" ignorereturn="1" />
    <Msi productcode="{DCDAB2ED-5741-4C30-A1A4-0FCB8A529001}" file="ICA_X4.msi" cmdline="REMOVE=ALL" progresstext="Str.UpgradeProgressText" adminsupport="0" condition="REMOVE_14" scheduled="0" ignorereturn="1" />
    <Msi productcode="{92B60B3B-7DF3-4BF7-8823-9F17A9EEA31E}" file="WPO15\Setup.msi" progresstext="Str.ProgressText.Common" cmdline="ICA_ALL_PUBLIC" managed="1">
    <Dbm productcode="{71D2F8EE-9D45-4D95-A6F6-F6433C2B94B5}" file="WPO15\ENSystem.msi" progresstext="Str.ProgressText.Common" adminsupport="0"/>
    <Dbm productcode="{EC61C6D9-159B-4B14-AAF3-AF33FCFA50DD}" file="WPO15\ENWP.msi" cmdline="ADDVIEWERS=[ADDVIEWERS]" progresstext="Str.ProgressText.WP" />
    <Dbm productcode="{DAEDCD3D-B981-4F10-B17B-764753EDAF9F}" file="WPO15\ENQP.msi" progresstext="Str.ProgressText.QP" />
    <Dbm productcode="{378BAC91-3AE8-45F0-90E4-4F81E3EAEBC5}" file="WPO15\ENPR.msi" progresstext="Str.ProgressText.PR" />
    <Dbm productcode="{17C5A285-F7B6-492B-8F3B-343D02B84D75}" file="WPO15\ENCommon.msi" progresstext="Str.ProgressText.Common" cmdline="ESTIMATEDSIZE=[ICA.DiskSpace.Drive.Required.0] PIDPREFIX=WP15" />
    <Dbm productcode="{D7643510-C1AE-44AD-B0F9-0665C4D73BFD}" file="WPO15\LegalTools.msi" progresstext="Str.ProgressText.WP" />
    <Dbm productcode="{CD5C6C29-E6CB-4DF3-B45F-A04087B1C294}" file="WPO15\ENTemplates.msi" progresstext="Str.ProgressText.WP" />
    <Dbm productcode="{E67732DE-3387-4F1E-BDDA-2D0C08BC025B}" file="WPO15\ENFilters.msi" progresstext="Str.ProgressText.Common"/>
    <Dbm productcode="{6E4B1E42-A831-44B4-A705-D006F68560EC}" file="WPO15\ENGraphics.msi" progresstext="Str.ProgressText.Common"/>
    <Dbm productcode="{19B4CD07-1919-4002-B28F-A5D2027026E0}" file="WPO15\IPM.msi" progresstext="Str.ProgressText.Common" cmdline="PCUSOURCEID=[PCUSOURCEID] ALLOW_PRODUCTUPDATES=&quot;[ALLOW_PRODUCTUPDATES]&quot; SERIALNUMBER=&quot;[SERIALNUMBER]&quot; USERNAME=&quot;[USERNAME]&quot; SHOW_EULA=[AcceptLicense] SKU=[SKU]"/>
    <Dbm productcode="{E539B721-4458-4EFC-8BD0-04D4842051AE}" file="WPO15\EN.msi" progresstext="Str.ProgressText.EN" cmdline="SKUDATA=&quot;[SKUDATA]&quot;" />
    <Dbm productcode="{D4167D08-0F61-4F44-BC3F-26B4960745C4}" file="WPO15\ENSkins.msi" progresstext="Str.ProgressText.EN" />
    <Dbm productcode="{64459BD5-3AE8-4689-B7B0-D57B667D8399}" file="WPO15\ENPExp.msi" progresstext="Str.ProgressText.Common" />
    <Dbm productcode="{1F0D7D15-8A36-4AE4-8573-70BEA7DF379D}" file="WPO15\MMan_EN.msi" progresstext="Str.ProgressText.Common" />
    Last edited by ssl6 (2012-04-10 02:05:44)

  • Can I automate a VI to test hardware through CAN with some sort of script?

    I am trying to automate some hardware testing over the CAN bus.   I have started a basic VI that I can manually run these tests, but there are testing scripts available to me and I was wondering if there is a way to import some sort of scripts (or similar) into LABView to automatically run my VI to perform the test.  I've done some searches, but looking for scripting only comes up with MathScript that MATLAB related information.
    Thanks for the help.

    stupidlogic wrote:
    Thank you very much for the help.  To be honest, I'm new to LabVIEW development and so I don't have any experience in importing scripts whatsoever.  Assuming I have the script written in the suggested format...
    Do I keep it saved as a .xls?
    What subVI block do I import it into LabVIEW with?
    Also, I haven't looked at every script I'll be dealing with (only a couple) and therefore, I don't know how complex it may get.  Do you know where I can access some resources on learning to use TestStand?  I've never used it before.  Even just answering the basic, what does it do/how does it work would be helpful.
    Once again, I appreciate all the assistance.
    We may be calling it as script,but to the core,you are developing an appication to read excel sheet,your logic should segragate each steps action and you should have LabVIEW code wherever an action is required. If you are planning to do this task in LabVIEW, you need following steps to finish.
    VI to read your excel sheet and format it to a 2-Dimensional array(Format the array to remove unnecesary characters).
    A state machine(code architecture) which will be guided as per the states in your excel sheet.
    A hardware handling loop to generate and acquire data for your main code(state machine).
    Use CAN Channel API in case you have a defined CAN dbc file.
    If no dbc file, go for frame API.
    In case you are using TestStand, you need go for an architecture where your CAN periodic data transmission is taken care using LabVIEW.
    Honestly it's not the task of a novice LabVIEW\TestStand programmer if you have less time ro learn. If you provide your e-mail address, I can send you a scaled down code after removing proprietary stuff. 
    Following link is an introductuction to Teststand:
    http://zone.ni.com/devzone/cda/tut/p/id/6073
    Regarding availability of resources to learn LabVIEW and TestStand,Can any one who is following this thread can suggest any materials ?

  • Need some help with a sort

    I'm trying to make a program that produces a 2-D array and graphically sorts the numbers inside of it. In one column is the random numbers and in the other are the x values for the bars that represent the length of each random number. What I want the program to do is step through the array and find the smallest random number (in column 0) and move it to the appropriate spot in the array sorting from smallest to largest. As the random numbers in column 0 move I also want the x values in column 1 to swap the same way. I have this set up with a timer so that you can see the sort take place one step at a time but there's something wrong with the way I have my sort set up because it's not working properly. I just need some direction on how to get that part of it to work.
    Here's the code for the main method:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Sort2
       public static void main (String[] args)
          JFrame frame = new JFrame ("Sort");
          frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().add(new SortPanel2());
          frame.pack();
          frame.setVisible(true);
    }

    Here's the panel code:
    import java.util.Random;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SortPanel2 extends JPanel
         private final int DELAY = 1000;
        private final int WIDTH = 800, HEIGHT = 400, BARWIDTH = 20;
        public static int y=0;
        public static int index = 0, scan;
        private int h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13,h14,h15;
         private Timer timer;
         public int [][] randomnumbers = new int[15][2];
         public SortPanel2()
               timer = new Timer(DELAY, new SortListener());
               setPreferredSize (new Dimension(WIDTH, HEIGHT));
               setBackground (Color.white);
               timer.start();
              Random gen = new Random();
              for (int x=0; x < 15; x++)
                   randomnumbers[x][0] = gen.nextInt(100)+10;
                   randomnumbers[x][1] = (50*x) +50;
              h1 = randomnumbers[0][0] * 3;
              h2 = randomnumbers[1][0] * 3;
              h3 = randomnumbers[2][0] * 3;
              h4 = randomnumbers[3][0] * 3;
              h5 = randomnumbers[4][0] * 3;
              h6 = randomnumbers[5][0] * 3;
              h7 = randomnumbers[6][0] * 3;
              h8 = randomnumbers[7][0] * 3;
              h9 = randomnumbers[8][0] * 3;
              h10 = randomnumbers[9][0] * 3;
              h11 = randomnumbers[10][0] * 3;
              h12 = randomnumbers[11][0] * 3;
              h13 = randomnumbers[12][0] * 3;
              h14 = randomnumbers[13][0] * 3;
              h15 = randomnumbers[14][0] * 3;
              for (int y=0;y < 15; y++)
              System.out.println(randomnumbers[y][0]);
            public void paintComponent (Graphics page)
               super.paintComponent (page);
               page.setColor(Color.red);
               page.fillRect(randomnumbers[0][1], 0, BARWIDTH, h1);
               page.setColor(Color.black);
               page.fillRect(randomnumbers[1][1], 0, BARWIDTH, h2);
               page.setColor(Color.blue);
               page.fillRect(randomnumbers[2][1], 0, BARWIDTH, h3);
               page.setColor(Color.orange);
               page.fillRect(randomnumbers[3][1], 0, BARWIDTH, h4);
               page.setColor(Color.yellow);
               page.fillRect(randomnumbers[4][1], 0, BARWIDTH, h5);
               page.setColor(Color.green);
               page.fillRect(randomnumbers[5][1], 0, BARWIDTH, h6);
               page.setColor(Color.cyan);
               page.fillRect(randomnumbers[6][1], 0, BARWIDTH, h7);
               page.setColor(Color.magenta);
               page.fillRect(randomnumbers[7][1], 0, BARWIDTH, h8);
               page.setColor(Color.pink);
               page.fillRect(randomnumbers[8][1], 0, BARWIDTH, h9);
               page.setColor(Color.gray);
               page.fillRect(randomnumbers[9][1], 0, BARWIDTH, h10);
               page.setColor(Color.lightGray);
               page.fillRect(randomnumbers[10][1], 0, BARWIDTH, h11);
               page.setColor(Color.darkGray);
               page.fillRect(randomnumbers[11][1], 0, BARWIDTH, h12);
               page.setColor(Color.red);
               page.fillRect(randomnumbers[12][1], 0, BARWIDTH, h13);
               page.setColor(Color.yellow);
               page.fillRect(randomnumbers[13][1], 0, BARWIDTH, h14);
               page.setColor(Color.blue);
               page.fillRect(randomnumbers[14][1], 0, BARWIDTH, h15);
            private class SortListener implements ActionListener
               public void actionPerformed (ActionEvent event)
             int min;
             int temp1, temp2;
                  while (index < randomnumbers.length)
                        min = index;
                        scan = index + 1;
                        System.out.println("Scan="+scan);
                        while (scan < randomnumbers.length)
                         if (randomnumbers[scan][0] < randomnumbers[min][0])
                              min = scan;
                              System.out.println("Minimum: "+randomnumbers[min][0]+" Minimum Address: "+ min);
                                  temp1 = randomnumbers[min][0];
                                  temp2 = randomnumbers[min][1];
                                  randomnumbers[min][0] = randomnumbers[index][0];
                                  randomnumbers[min][1] = randomnumbers[index][1];
                                  randomnumbers[index][0] = temp1;
                                  randomnumbers[index][1] = temp2;
                         scan ++;
                        index++;
                     repaint();
    }

  • [SOLVED] Need a little help with ACPI handler.sh script.

    By using ACPI I'm trying to get my laptop to hibernate at critical power state. So far I've made a few test scripts to test how to do this, with one of these scripts I'm stuck. My scripting skills are not that good to solve it.
    This is the script:
    if [ `awk '{print $3}' /proc/acpi/battery/C1E9/state` == "ok" ]
    then
    logger "battery is ok"
    else
    logger "battery is not ok"
    fi
    If I run the script I get an error (while "battery is not ok" is logged):
    ┌─[~]
    └─> ./test2
    ./test2: line 1: [: too many arguments
    ┌─[~]
    └─>
    When I run the awk-command from the script, I get the following output:
    ┌─[~]
    └─> awk '{print $3}' /proc/acpi/battery/C1E9/state
    ok
    discharging
    2341
    1824
    10969
    ┌─[~]
    └─>
    I think the problem lies in the multiple output of the awk-command, but I'm stuck in solving it.
    Any help would be great.
    Last edited by NeoXP (2009-11-16 22:40:45)

    @ skanky
    Thanks for the suggestion, but you're right I'm not gonna change a working script. It is working exactly as expected.
    @ all
    When interested this is my current handler.sh
    #!/bin/sh
    # Default acpi script that takes an entry for all actions
    # NOTE: This is a 2.6-centric script. If you use 2.4.x, you'll have to
    # modify it to not use /sys
    minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
    maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
    setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
    set $*
    case "$1" in
    button/power)
    echo "PowerButton pressed!">/dev/tty5
    case "$2" in
    PWRF) logger "PowerButton pressed: $2" ;;
    *) logger "ACPI action undefined: $2" ;;
    esac
    button/sleep)
    case "$2" in
    SLPB) echo -n mem >/sys/power/state ;;
    *) logger "ACPI action undefined: $2" ;;
    esac
    ac_adapter)
    case "$2" in
    AC)
    case "$4" in
    00000000)
    echo -n $minspeed >$setspeed
    #/etc/laptop-mode/laptop-mode start
    00000001)
    echo -n $maxspeed >$setspeed
    #/etc/laptop-mode/laptop-mode stop
    esac
    *) logger "ACPI action undefined: $2" ;;
    esac
    battery)
    if [ `awk '{print $2}' /proc/acpi/ac_adapter/C1E8/state` == "off-line" ];
    then
    logger "battery discharging"
    if (( `awk '{if (NR==5) {print $3}}' /proc/acpi/battery/C1E9/state` >= "250" ))
    then
    logger "battery ok"
    else
    logger "battery not ok"
    /usr/sbin/pm-hibernate;
    fi
    else logger "battery charging"
    fi
    button/lid)
    if [ `awk '{print $2}' /proc/acpi/button/lid/C1ED/state` == "closed" ];
    then
    logger "ACPI lid closed"
    /usr/sbin/pm-suspend
    fi
    logger "ACPI group/action undefined: $1 / $2"
    esac
    Still working on it though

  • Need Help with Array.sort and compare

    Hi
    I have a big problem, i try to make a java class, where i can open a file and add new words, and to sort them in a right order
    Ok everthing works fine, but i get a problem with lower and upper cases.
    So i need a comparator, i tried everything but i just dont understand it.
    How do i use this with Array.sort??
    I hope someone can help me

    Okay, you want to ignore case when sorting.
    There are two possibilities: Truly ignore case, so that any of the following are possible, and which one you'll actually get is undefined, and may vary depending on, say, which order the words are entered in the first place:
    English english German german
    english English german German
    English english german German
    english English German german
    The second possibility is that you do consider case, but it's of lower priority--it's only considered if the letters are the same. This allows only the first two orderings above.
    Either way, you need to write a comparator, and call an Arrays.sort method that takes both array and Comparator.
    The first situation is simpler. Just get an all upper or lower case copy of the strings, and then compare thosepublic int compare(Object o1, Object o2) {
        String s1 = ((String)o1).toUpper();
        String s2 = ((String)o1).toUpper();
        return s1.compareTo(s2);
    } You'll need to add your own null check if you need one.
    For the second way, your comparator will need to iterate over each pair of characters. If the characters are equal, ignoring case, then you compare them based on case. You pick whether upper is greater or less than lower.
    Of course, the need to do this assumes that such a method doesn't alrady exist. I don't know of one, but I haven't looked.

  • Help with difficult numbers formula

    I need help with a formula im trying to create in numbers on my iPad. I'll try to explaine the best I can and attach images to help.
    Ive created a spreadsheet to do rotas for work. Currently it calculates the shifts each person does and adds it to the total for that persons week in the end column and the total for the day in the bottom row. If the shift is equal to or more than 8 hours long then an hour needs to be deducted as they have a lunch hour that is unpaid for. This is currently done by a hidden row under each persons row that calculates the shift for that person on that day with the given conditions. Also is a 'H' (for holiday), 'RDO' (for requested day off) or 'X' (for unable to work this day) is placed in any of the cells the formular will return value 0. What I am wanting to do is to get rid of all the hidden rows and still have the total calculated in the end column for that person and the day in the bottom row. Is there a way of doing this without having to copy the formula in the hidden cell and adding them in series for each day to achieve the total? I hope this makes sense. Ive attached images to try and help with the explanation.
    Thanks in advance

    Hi Gary,
    I believe that it is generally good practice to choose several smaller formulas over large and complex ones. As you noted in your question you could add your daily IF()s to get the result you want but it would be an unwieldy construction. I also suspect that the daily hours for each employee could be useful info.
    I hope things are working out for you.
    quinn

  • Applescript help with true or false script

    I'm in need of a applescript that will run two different scripts based on the outcome of an existing file.
    I have a folder called Status. Inside this folder is a simple text file called Good.rtf
    I would like a script that would run one or the other script base on the true or false output.  If file exists then:
    true will
    run script A
    false will
    run script B
    I have been searching the web for two days looking for something to help me get started on this and have not had much success.
    Please help me.   I really would appropriate any help or guidance. 
    Thanks....
    Ron

    Ron
    AppleScript calls this kind of script a "Conditional" = if this > then that
    Some templates are in MacintoshHD/Library/Scripts/Script Editor Scripts/Conditionals
    You don't need a value for "false" in binary as it is merely "not true" (else)
    if true then
        -- insert if actions here
    else
        -- insert else actions here
    end if
    If you already have your Scripts A & B working, copy>pastethem into the "insert actions here" part as appropriate
    ÇÇÇ

  • Help with selecting files from script menu or drag and drop

    I found this scale images applescript online. It works great when a bunch of files is dragged on top of the script but I would like it to also work when a folder or group of files is selected in the Finder and I activate it from the scripts menu.
    I can't get my on run statement to work. I'm not really an Applescript guy so I'm really just asking if someone can help finish what I started in this on run.
    -- save in Script Editor as Application
    -- drag files to its icon in Finder
    property target_width : 120
    property save_folder : ""
    on run
    tell application "Finder"
    activate
    set folder_path to quoted form of (POSIX path of (the selection as alias))
    set theItems to every file of folder_path
    end tell
    end run
    on open some_items
    -- do some set up
    tell application "Finder"
    -- get the target width, the default answer is the property target_width
    set new_width to text returned of ¬
    (display dialog "Target width:" default answer target_width ¬
    buttons {"OK"} default button "OK")
    if new_width as integer > 0 then
    set target_width to new_width
    end if
    -- if the save_folder property has not been set,
    -- set it to the folder containing the original image
    if save_folder is "" then
    set save_folder to ¬
    (container of file (item 1 of some_items) as string)
    end if
    -- get the folder to save the scaled images in,
    -- default folder is the property save_folder
    set temp_folder to ¬
    choose folder with prompt ¬
    "Save scaled images in:" default location alias save_folder
    set save_folder to temp_folder as string
    end tell
    -- loop through the images, scale them and save them
    repeat with this_item in some_items
    try
    rescaleand_save(thisitem)
    end try
    end repeat
    tell application "Image Events" to quit
    end open
    on rescaleand_save(thisitem)
    tell application "Finder"
    set new_item to save_folder & "scaled." & (name of this_item)
    end tell
    tell application "Image Events"
    launch
    -- open the image file
    set this_image to open this_item
    set typ to this_image's file type
    copy dimensions of this_image to {current_width, current_height}
    scale this_image by factor (target_width / current_width)
    save this_image in new_item as typ
    end tell
    end rescaleandsave

    When items are dragged to your script's icon they are passed in to the on open handler, so this triggers:
    on open some_items
    and the dragged items are passed in as some_items
    In contrast, when you double-click on the script, or invoke it via the Script menu, this runs the on run handler:
    on run
      tell application "Finder"
        activate
        folder_path to quoted form of (POSIX path of (the selection as alias))
        set theItems to every file of folder_path
      end tell
    end run
    However, there's nothing in this block that actually does anything with the selection - you (dangerously) assume that the selection is a folder (you really should check first), and just set theItems to every file in that folder then you exit.
    So to do what you want you'll need to edit your run handler to filter the selection and pass files over to the code that does the hard work.
    You already have the basis for this - your rescaleandsave() handler, so it's just a matter of identifying the files in the selection and passing those over to that handler:
    on run
      tell application "Finder"
        set cur_selection to (get selection) -- get the selection
        repeat with each_item in cur_selection -- iterate through
          if class of each_item is folder then -- do we have a folder?
            set theFiles to every file of each_item -- if so, get its contents
            repeat with each_file in theFiles -- iterate through them
              my rescaleand_save(eachfile) -- and process them
            end repeat
          else if class of each_item is document file then -- do we have a file selected?
            my rescaleand_save(eachitem) -- if so, process it
          end if
        end repeat
      end tell
    end run
    So the idea here is that the run handler gets the selection and works through the (potentially-numerous) items. For each selected item it checks whether its a folder or a file, if its a folder it gets all the files within and passes them to the rescaleandsave handler.
    Note that this is not recursive - it won't catch files within folders within folders - since it only looks at the top level of selected folders, but it wouldn't be hard to rework the script to handle that if that's what you need.

  • Help with EEM TCL / CLI scripting for re-direction/wccp counters

    Being new with EEM scripting I wanted to see if I was on the right track and get some help to finish my idea.
    Our problem I am trying to fix is our remote sites utilize pairs of Cat3650's for some routing and WCCP redirection.  We are encountering ACL denial issues causing slow down and access issues.  The fix for the issue we remove the WCCP service groups to break peering with our wan optimizers and re-insert the configuration thus re-establishing peering and restoring service.
    My idea is to use a TCL scipt on a watchdog timer to parse the "sh ip wccp | inc denied (or unassign)" output for denial and unassignable error counters.  If a counter is found I wanted to create a syslog message that would then kick off a simple EEM CLI script to remove the service groups, wait 10 seconds, then re-add the service groups.  Please point me in the right direction if I am off track as I am not sure if I can use the EEM CLI for all this or since I want to retreive specific info from the sh ip wccp output if I do need to utilize TCL.  I am also unsure if the "total denied" ascii string pulled via the "sh ip wccp | inc denied" will cause issues when attempting to just pull the counter information.
    sh ip wccp | inc Denied Red
            Total Packets Denied Redirect:       0
            Total Packets Denied Redirect:       0
    Script thus far :
    TCL
    if [catch {context_retrieve "EEM_WCCP_ERROR_COUNTER" "count"} result] {
    set wccpcounter 0
    } else {
    set wccpcounter $result
    } if [catch {cli_open} result] {
    error $result
    } else {
    array set cli $result
    } if [catch {cli_exec $cli(fd) "show ip wccp | incl Denied"} result] {
    error $result
    } else {
    set cmd_output $result
    set count ""
    catch [regexp {receive ([0-9]+),} $cmd_output} ignore count]
    set count
    set diff [expr $count - $wccpcounter]
    if {$diff != 0} {
    action_syslog priority emergencies msg "WCCP counters showing incremental Denied packet counts"
    if [catch {cli_close $cli(fd) $cli(tty_id)} result] {
    error $result
    context_save EEM_WCCP_ERROR_COUNTER count
    CLI
    event manager applet WCCP_COUNTER_WATCH
    event syslog priority emergencies pattern "WCCP counters showing incremental Denied packet counts"
    action 001 cli command "enable"
    action 002 cli command "config t"
    action 003 cli command "no ip wccp 61"
    action 004 cli command "no ip wccp 62"
    action 005 wait 10
    action 006 cli command "ip wccp 61"
    action 007 cli command "ip wccp 62"
    action 008 wait 15
    action 009 cli command "clear ip wccp"
    action 010 cli command "end"
    Thanks for all the help

    This won't work as EEM cannot intercept its own syslog messages.  However, I'm not sure why you need this form of IPC anyway.  Why not just make the Tcl script perform the needed CLI commands?
    And, yes, you could use all applets here.  But since you've written the hard stuff in Tcl already, it might be best just to add the missing calls to reconfigure WCCP to that script.

  • I need help with searching for an image inside another image

    I need to write a program that checks for a specific image (a jpg) inside another, larger, image (a jpg). If so, it returns a value of true. Can anyone help me?
    Winner takes all. First person to solve this gets 10 dukes.
    Please help.

    Hi,
    I would use a full screen image Sequence made with png for transparency and put your article behind. no auto play, stop at first and last image. and information for swipe to display article.

  • Flash Newbie needs help with Movie Clips/Action Scripting

    Hi -
    I'm having a problem with my movie clips playing
    simultaneously and cannot, for the life of me, figure out what I
    have done wrong. I'm new to flash, so I may have set something up
    incorrectly, but here's what I have so far:
    11 layers, total: 1 layer with 10 control buttons, each
    button with the following actionscript:
    on (release) {
    gotoAndPlay(85);
    Where the number changes in relation to which keyframe the
    next movie is on.
    I have 10 movies, total, but they are only movie clips,
    essentially photo slide shows with audio, made all in the library.
    The problem happens when I click on the second or third
    button. Not only does the movie that I have selected begin to play,
    but all of the previous clips do as well, so it all sounds quite
    garbled. I don't know what I am missing in the action script, as my
    Action Layer has a stop command on it at each keyframe where there
    is a new clip to play.
    I have tried to add a stopAllSounds command, but I'm afraid
    that doesn't do anything because it is not a "sound file" per se,
    playing in the timeline.
    I'm at the end of my rope and really need some help in
    figuring this one out. My project is hanging in the balance on
    this, as I have scripted everything else correctly and it runs
    beautifully.
    Please help!
    Thanks,
    Caroline

    Each layer has a blank keyframe before and after each
    movieclip. Each movie clip is at a different frame. Even with the
    blank keyframes added, the second video starts to play and then the
    first video begins to play. Same happens if I click on the third
    button. Third plays, and starts 1st and 2nd shortly thereafter. Is
    there an action script I can put in that will tell the timeline
    that, when a button is clicked, no matter where the movieclip is,
    it will stop and start the newly selected movieclip?

  • Help with UCCX 8.5 scripting and xmls

    I have a customer with multiple scripts, we are moving them from 3.5 to 8.5 which is running on VMWare.  Here's my scenario:
    The caller can call the trigger 54779, enter a #, then a password of 12345.  Then they can set a normal condition by dialing 1, an after-hours condition by dialing 2, or an emergency condition by dialing 3.  I’m testing the “2” condition now. In the previous 3.5 system, if they dialed 2, the system copied the Doc “2.xml” and copied it to the Doc "Carolina_Access_Emergency_Check.xml", both of which are in the en_US folder in the Documents section.
    I can’t get this thing to change my document "Carolina_Access_Emergency_Check.xml". All I know is that it goes, “unsuccessful”. I’m pretty sure the authentication is working since it gets by that step.  If we can’t get the “copy” to work, really all I need to do with this option 2, is for the data in "Carolina_Access_Emergency_Check.xml" in <TYPE>1</TYPE> to change from a 1 to a 2." I'm attaching a zip with the old and new scripts along with the 2 xml files i'm referring to.  I need help on this one, please!

    Has the user you setup have Application Admin rights? I had this issue when I was trying to create an Emergency shutdown script and the user did not have sufficient rights.
    I don't mind sharing this script I created ,which effectively changes a value from 1 to a 2, which seems to be what you are trying to do but I can not figure out how to share it with you here. You could then use this as example to achieve what you are trying to do.

  • Help with a program Option Script

    I need some help writing a Option Frame for a Add-in on my program. The basic thing it will do is to call a KeyListener with a KeyAdapter, wait for a key to be pressed, assign the key that was pressed to an int (i.e. LEFT for e.VK_LEFT) and send it to my main program. I don't have the script completely written yet, but I'm not sure how I can send 7 int values to my main program at the same time. I was thinking of something like:
    LEFT = KA_Options.getIntLEFT(int temp_LEFT);but if their is an easier way to get all the int's called at once instead of calling 7 different classes everytime a key is pressed in my main program (because of Beta testing, I don't exactly want to assign them to their own int values intill I get the code almost bug free). I would like to put my main program in this thread, but the hugeness of it, it would make reading the posts hard.
    Thanks,
    g@m3r

    This is the basic working code for my KA_Options script
         KA Option Pop-up
         Version 0.1b
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class KA_Options extends Frame implements ActionListener
         String title= "KA Options 0.1b";
         int LEFT, RIGHT, UP, DOWN, A, S, D; //The Directional Ints
         MenuBar kamenu = new MenuBar();
         Menu file = new Menu("File");
              MenuItem file_close = new MenuItem("Close");
         Menu options = new Menu("Options");
              MenuItem options_default = new MenuItem("Default Controls");
         public static void main(String[] args)
              KA_Options window = new KA_Options();
         public KA_Options()
              setTitle(title);
              setSize(100,100);
              setResizable(false);
              setLocation(0,200);
              KAMenuSetup_v1b();
                   setMenuBar(kamenu);
              addWindowListener(new WindowAdapter()
                   { public void windowClosing(WindowEvent e)
                        { setVisible(false); }
              pack();
         public void KAMenuSetup_v1b() //Beta
              kamenu.add(file);
                   file.add(file_close);
                        file_close.setActionCommand("Close");
                        file_close.addActionListener(this);
              kamenu.add(options);
                   options.add(options_default);
                        //options_default.setActionCommand("Default");
                        //options_default.addActionListener(this);
         public int getIntLEFT()
              return LEFT;
         public int getIntRIGHT()
              return RIGHT;
         public int getIntUP()
              return UP;
         public int getIntDOWN()
              return DOWN;
         public int getIntA()
              return A;
         public int getIntS()
              return S;
         public int getIntD()
              return D;
         public void actionPerformed(ActionEvent e)
              String arg = e.getActionCommand();
              if(arg == "Close")
                   { setVisible(false); }
    } I'm still writing the bulk of the code.

  • Help with a date field script

    Sorry if this is a repeat. I was interrupted and found that my browser had crashed when I came back so I'm not sure if the question got asked.
    I need a script for a date field (mm/dd/yyyy) where the user can only fill in a date that is between 12/31/1899 and the current date (whatever the date when the form is opened). I'm getting better at writing these but I haven't been successful with this one. Any help would be greatly appreciated.
    Thanks!

    I have a feeling I already answered this question some time ago... Anyway, you can use this code as the field's custom validation script:
    var minDate = util.scand("mm/dd/yyyy", "12/31/1899");
    var maxDate = new Date();
    event.rc = true;
    if (event.value) {
        var d = util.scand("mm/dd/yyyy", event.value);
        if (d<minDate || d>maxDate) {
            app.alert("Error! The entered date must be between " + util.printd("mm/dd/yyyy", minDate) + " and " + util.printd("mm/dd/yyyy", maxDate));
            event.rc = false;

Maybe you are looking for