Script doesn't take all the files in the folder

I have compiled a script from different resources. It pads images to specified dimensions.  But I can't get it to process all the images in a folder. It only does one.
Here is the script.
(* IMPORTANT: The with pad color parameter of the pad command does not work in Mac OS 10.5.5. Use4 the SIPS command-line utility instead when padding with a color *)
set this_folder to (choose folder with prompt "Pick the folder containing the files to process:") as string
tell application "System Events"
  set these_files to every file of folder this_folder
end tell
repeat with i from 1 to the count of these_files
  set this_file to (item i of these_files as alias)
  set this_info to info for this_file
end repeat
property target_dimensions : "1024, 768"
property default_color : {0, 0, 0}
set this_path to the quoted form of the POSIX path of this_file
-- get the final dimensions for the padded image
repeat
display dialog "Enter the target dimensions for the padded image:" & return & return & "target width, target height" default answer target_dimensions buttons {"Cancel", "Set Color", "Continue"} default button 3
  copy the result to {text returned:dimensions_string, button returned:button_pressed}
  if the button_pressed is "Set Color" then
  set the default_color to choose color default color default_color
  else
  try
  if the dimensions_string does not contain "," then error
  set AppleScript's text item delimiters to ","
  copy every text item of the dimensions_string to {width_string, height_string}
  set AppleScript's text item delimiters to ""
  set target_W to width_string as integer
  set target_H to height_string as integer
  if target_W is less than 1 then error
  if target_H is less than 1 then error
  set the target_dimensions to (target_W & ", " & target_H) as string
  exit repeat
  on error
  beep
  end try
  end if
end repeat
set the hex_color to text 2 thru -1 of (my RBG_to_HTML(default_color))
try
  tell application "Image Events"
  -- start the Image Events application
  launch
  -- open the image file
  set this_image to open this_file
  -- get dimensions of the image
  copy dimensions of this_image to {W, H}
  -- calculate scaling
  if target_W is greater than target_H then
  if W is greater than H then
  set the scale_length to (W * target_H) / H
  set the scale_length to round scale_length rounding as taught in school
  else
  set the scale_length to target_H
  end if
  else if target_H is greater than target_W then
  if H is greater than W then
  set the scale_length to (H * target_W) / W
  set the scale_length to round scale_length rounding as taught in school
  else
  set the scale_length to target_W
  end if
  else -- square pad area
  set the scale_length to target_H
  end if
  -- perform action
  scale this_image to size scale_length
  (* The with pad color parameter is broken in Mac OS X 10.5.5
  -- perform action
  pad this_image to dimensions {target_W, target_H} with pad color default_color
  -- save the changes
  save this_image with icon
  -- purge the open image data
  close this_image
  end tell
-- The with pad color parameter is not working in 10.5.5 so use the SIPS command-line utitlity instead
do shell script "sips " & this_path & " -p " & target_H & space & target_W & space & "--padColor " & hex_color & space & "-i"
on error error_message
display dialog error_message buttons {"Cancel"} default button 1
end try
on RBG_to_HTML(RGB_values)
-- NOTE: this sub-routine expects the RBG values to be from 0 to 65535
  set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
  set the the hex_value to ""
  repeat with i from 1 to the count of the RGB_values
  set this_value to (item i of the RGB_values) div 256
  if this_value is 256 then set this_value to 255
  set x to item ((this_value div 16) + 1) of the hex_list
  set y to item (((this_value / 16 mod 1) * 16) + 1) of the hex_list
  set the hex_value to (the hex_value & x & y) as string
  end repeat
  return ("#" & the hex_value) as string
end RBG_to_HTML

The problem is this repeat loop
repeat with i from 1 to the count of these_files 
  set this_file to (item i of these_files as alias) 
  set this_info to info for this_file 
end repeat 
It goes through every file in the folder but only sets the variable this_file to one file. When the loop is finished this_file is only pointing to one file, which is the file that will be processed.
A few ways to handle this, the easiest is to move the
end repeat
at line 5 to the just after the do shell script at line 81.

Similar Messages

  • Analyse big data in Excel? Why the dynamic tables doesn't take all the data from the source table.

    Hi,
    I'm doing a internship in a production line.
    My job is to recover production data (input data) and test data (output data) using various types of software (excel, BusinessObject sap, etc).
    To this day, I have recovered hundreds of production data, and have also organized in excel but I need to analyze and plot them.
    I would like to know who can give me an idea of ​​how I could plot as much data and analysis.
    Now i trying to use dynamic charts and plot some data but I did not get acceptable answers.
    How could I compare, analyze and graph for example:
    Five columns of production (input) with five (5) columns tested (data output).
    After graphing.
    Someone can give me a technique to analyze data? ie I compare column by column?
    or some other technique? as a conglomerate could analyze data?
    o give you an idea of ​​the contect, now I perform an internship in a manufacturing turbines.
    My job is to analyze the input data (production) and to estimate the possible behavior of the turbines in the tests.
    As I said, use dynamic tables in excel, but i have not idea why the dynamic tables doesn't  take all the data from the source table.
    I appreciate your advice
    Thanks

    You can declare as PT source whole Columns [$A:$E], without rows number.
    Then You'll have all actually data.
    Oskar Shon, Office System MVP - www.VBATools.pl
    if Helpful; Answer when a problem solved

  • FullScreen script doesn't work all the time

    I am having a problem with this script. Its weird, sometimes I type in a number like 3333 and it will go to the google link like this:
    http://www.google.com/maps?saddr=3333&daddr=40.000000,80.000000
    Other times I type in the same number and it doesn't work.
    Anyone see any problems with the code?
    echo "<script language=\"Javascript\">
    <!--
    var str = \"left=0,screenX=0,top=0,screenY=0\";
    if (window.screen){
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;
    str += \",height=\" + ah;
    str += \",innerHeight=\" + ah;
    str += \",width=\" + aw;
    str += \",innerWidth=\" + aw;
    } else {
    str += \",resizable\";
    function call_full() {
    var saddr=document.getElementById('saddr').value;
    var daddr=document.getElementById('daddr').value;
    fullScreen('http://maps.google.com/maps?saddr='+saddr+'&daddr='+daddr+'')
    //-->
    </script>";
    echo '<form name="addr_form" id="addr_form">
    <b>Get Directions</b>
    <br>
    <font size=2>Your address: (street, town, state)</font><br>
    <input type="text" size=40 maxlength=40 name="saddr" id="saddr" value="" />
    <input type="button" type="submit" onClick="call_full()" value="Go">
    <input type="hidden" name="daddr" value="40.00000, -80.00000"/>
    </form>';Message was edited by:
    [email protected]

    The main problem I see is that it's written in Javascript, and this is a forum about Java, not about Javascript.
    I can tell you that in Java there's a method available to URL-encode URL parameter values. For all I know there's one in Javascript too. There should be, in my opinion, but not knowing the language very well I couldn't tell you if there really is one.

  • Videos take all the screen in Full Screen mode!!!!!

    I mean, if you have a flash, and a video on it, which is smaller than the size of the flash, AND if the project is set to be in Full Screen, then, when you publish it and test the .exe, the video will TAKE all the screen area!
    I have included some pictures so you can see what I mean.
    This is how it SHOULD be in full scree, and how it IS if it's not in full screen:
    And this is how it actually IS if I play it on Full Screen:
    I know, this is really weird. Try it by your self. Create a flash, insert a video that doesn't take all the screen, add the Full Screen CODE, publish it and execute the .EXE file. The video will fill all the Screen.
    HOW CAN I SOLVE IT??????????

    videoplayer.fullscreenTakeover = false;

  • Control image to report doesn't take all width

    I want to add and print a control to my report, but the control image doesn't take all the width avalaible on my report.
    It's stretched before the margin.
    Take a look to my exemple in attachement
    thanks
    Attachments:
    print_panel.vi ‏38 KB

    Hi,
    I regret to say that the image size is a known bug with the Report Generator. There is currently no workaround for this issue. The image size cannot be greater than a 1� margin on both sides. I hope you�ll be able to work around this. The issue will be fixed in a future version of LV.
    Danny G.
    Applications Engineer
    National Instruments

  • Script to take every 5th file from a folder and copy it to another folder

    How can I tell applescript to take every 5th file of a folder of say 2000 files and copy them to another location? I want to copy the 5th, 10, 15th, 20th files and so on of 2000 files so I will have only 400 files.
    I guess I want to make a list of all the files and then coerce that to the first and then increments of five but how do I do that?
    Thanks.
    Pedro

    Hi Pedro,
    The following script should do what you are asking for:
    *set theSourceFolder to choose folder with prompt "Select the source folder."*
    *set theTargetFolder to choose folder with prompt "Select the target folder."*
    *tell application "Finder"*
    *set theFiles to files of theSourceFolder*
    *repeat with k from 5 to (count theFiles) by 5*
    *move item k of theFiles to folder theTargetFolder*
    *end repeat*
    *end tell*
    Message was edited by: Pierre L.

  • Does anyone get a vibration sound when talking on the iPhone6? It doesn't happen all the time and happens with talking to different people.

    Does anyone get a vibration sound when talking on the iPhone6? It doesn't happen all the time and happens with talking to different people. I have tried to troubleshoot it, but can't find a answer.

    Hey CEVYNBARRY!
    Here is an article for you that will help you address this issue:
    Troubleshooting "A connection failure has occurred", "The specified server could not be found" or similar messages
    http://support.apple.com/kb/ts1843
    Take care, and thanks for visiting the Apple Support Communities.
    -Braden

  • Safari show all tabs doesn't work all the time

    It is annoying: safari show all tabs doesn't work all the time. The little icon to the right of the "New Tab" area sometimes works, and sometimes doesn't. The Shift Command Back-slash, sometimes works, and sometimes doesn't. I find no rhyme nor reason for this. I have a MacBook Pro, Mountain Lion, the latest updates. It doesn't matter if I am in Full Screen or not.
    I am quite confused regarding this.

    Open the Finder. From the Finder menu bar click Go > Go to Folder
    Type of copy paste the following:
    ~/Library/Caches/com.apple.Safari/Cache.db
    Click Go then move the Cache.db file to the Trash.
    Quit and relaunch Safari to test.
    If that helped, empty the cache more often from your keyboard.
    Command + Option + E

  • When first loading, FIREFOX doesn't open all the way.

    When I first open FIREFOX, it doesn't open all the way. When I open another, FIREFOX

    Hi weaver15,
    You should try changing your home page to:
    about:home
    I think this is probably the page you are looking for. If you don't know how to change the home page, you should take a look at the Knowledge Base article [[How to set the home page]].
    Hopefully this helps

  • IPad doesn't charge all the time

    Ipad doesn't charge all the time

    Could be the charger, cable or iPad. Plug the USB cable into your computer. It may say "Not Charging", however, it is charging slowly and will verify that the cable is good.
    Try this first - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.)
    The quickest way (and really the only way) to charge your iPad is with the included 10W or 12W (5W on Mini) USB Power Adapter. iPad will also charge, although more slowly, when attached to a computer with a high-power USB port (many recent Mac computers) or with an iPhone Power Adapter (5W). When attached to a computer via a standard USB port (2.5W, most PCs or older Mac computers) iPad will charge very slowly (but iPad indicates not charging). Make sure your computer is on while charging iPad via USB. If iPad is connected to a computer that’s turned off or is in sleep or standby mode, the iPad battery will continue to drain.
    Apple recommends that once a month you let the iPad fully discharge & then recharge to 100%.
    How to Calibrate Your Mac, iPhone, or iPad Battery
    http://www.macblend.com/how-to-calibrate-your-mac-iphone-or-ipad-battery/
    At this link http://www.tomshardware.com/reviews/galaxy-tab-android-tablet,3014-11.html , tests show that the iPad 2 battery (25 watt-hours) will charge to 90% in 3 hours 1 minute. It will charge to 100% in 4 hours 2 minutes. The new iPad has a larger capacity battery (42 watt-hours), so using the 10W charger will obviously take longer. If you are using your iPad while charging, it will take even longer. It's best to turn your new iPad OFF and charge over night. Also look at The iPad's charging challenge explained http://www.macworld.com/article/1150356/ipadcharging.html
    Also, if you have a 3rd generation iPad, look at
    Apple: iPad Battery Nothing to Get Charged Up About
    http://allthingsd.com/20120327/apple-ipad-battery-nothing-to-get-charged-up-abou t/
    Apple Explains New iPad's Continued Charging Beyond 100% Battery Level
    http://www.macrumors.com/2012/03/27/apple-explains-new-ipads-continued-charging- beyond-100-battery-level/
    New iPad Takes Much Longer to Charge Than iPad 2
    http://www.iphonehacks.com/2012/03/new-ipad-takes-much-longer-to-charge-than-ipa d-2.html
    Apple Batteries - iPad http://www.apple.com/batteries/ipad.html
    iPhone: Hardware troubleshooting (Power/Battery section also applies to iPad)
    http://support.apple.com/kb/TS2802
    Extend iPad Battery Life (Look at pjl123 comment)
    https://discussions.apple.com/thread/3921324?tstart=30
    iOS 7 Battery Life Draining Too Fast? It’s Easy to Fix
    http://osxdaily.com/2013/09/19/ios-7-battery-life-fix/
    New iPad Slow to Recharge, Barely Charges During Use
    http://www.pcworld.com/article/252326/new_ipad_slow_to_recharge_barely_charges_d uring_use.html
    iPad: Charging the battery
    http://support.apple.com/kb/HT4060
    Best Practices for iPad Battery Charging
    http://www.ilounge.com/index.php/articles/comments/best-practices-for-ipad-batte ry-charging/
    Tips About Charging for New iPad 3
    http://goodscool-electronics.blogspot.com/2012/04/tips-about-charging-for-new-ip ad-3.html
    How to Save and Prolong the battery life of your new ipad
    https://discussions.apple.com/thread/4480944?tstart=0
    Prolong battery lifespan for iPad / iPad 2 / iPad 3: charging tips
    http://thehowto.wikidot.com/prolong-battery-lifespan-for-ipad
    iPhone, iPod, Using the iPad Charger
    http://support.apple.com/kb/HT4327
    Install and use Battery Doctor HD
    http://itunes.apple.com/tw/app/battery-doctor-hd/id459702901?mt=8
    To Extend a Device’s Battery Life, Get to Know It Better
    http://tinyurl.com/b67c7xz
    iPad Battery Replacement
    http://www.apple.com/batteries/replacements.html
    In rare instances when using the Camera Connection Kit, you may notice that iPad does not charge after using the Camera Connection Kit. Disconnecting and reconnecting the iPad from the charger will resolve this issue.
     Cheers, Tom

  • Itunes doesn't add all the songs from my library

    Hi,
    Had to reinstall Itunes and now the program doesn't add all the songs from my library (roughly 4,000 songs). All that is added is maybe 20 songs, and always the same ones. It has worked perfectly before.
    I have tried to "pull" all the artist folders into the Itunes window, but it doesn't work. I have tried to set another folder as the Itunes library and then choose "add new folder", but only those 20 songs are added. I have made sure so that none of the files are copy protected or "read-only".
    Please, help!
    Best regards,
    Jonas

    Ok, I deleted the two files and upon startup iTunes did run that search wizard for music files. However, it only found 4 songs that are located on local harddisks, and did not (as far as I could see on the network status) even try to search on the network harddisk.
    One more thing though, that I forgot to mention before. I tried to solve this situation by installing an earlier version of iTunes... 4.6 i think, but when I tried to run the program it told me something like "Cannot read the file iTunes library.itl since it was created by a later version of iTunes". Where can i find that file, and should i remove it and try to add the songs with iTunes 4.6 instead?
    (Thanks so much for all your help!)

  • I am using a T61 ThinkPad with an external hard drive and my itunes library keeps disapearing but remains on the external drive. Any idea how to fix this so my music doesn't disapear all the time? It's a real drag pulling music back into iTunes each week.

    I am using a T61 ThinkPad with an external hard drive and my itunes library keeps disapearing but remains on the external drive. Any idea how to fix this so my music doesn't disapear all the time? It's a real drag pulling music back into iTunes each week

    In iTunes 11 uncheck the preferences setting in in the iTunes Preferences panel "Advanced > Copy Files to iTunes Media folder when adding to Library"

  • I have Elements 11. Sometimes, if I edit a photo in Elements Editor, the date gets changed to the current date. Why does that happen? It doesn't happen all the time, so I can't isolate the cause. Any ideas?

    I have Elements 11. Sometimes, if I edit a photo in Elements Editor, the date gets changed to the current date. Why does that happen? It doesn't happen all the time, so I can't isolate the cause. Any ideas?

    I have Elements 11. Sometimes, if I edit a photo in Elements Editor, the date gets changed to the current date. Why does that happen? It doesn't happen all the time, so I can't isolate the cause. Any ideas?

  • Help. I can´t slide to answer when the phone rings, and i´m missing a lot of phone calls! It doesn´t happens all the time but quite enough to be annoying. I´v restarted and updated it. Suggestions? Thanks

    Help. I can´t slide to answer when the phone rings, and i´m missing a lot of phone calls! It doesn´t happens all the time but quite enough to be annoying. I´v restarted and updated it. Suggestions? Thanks

    When you said you have no fax machines on your line, that does include computers directly connected to the phone line?
    The reason that I ask is a computer with a dial-up modem (a non broadband modem) that can connect to your phone line, can have software that makes the computer act as a fax machine.
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution?" button so that others can more easily find it. If anyone has been helpful to you, please show your appreciation by clicking the "Kudos" button.

  • My iPhone 5 dies at 20-24% it doesn't go all the way to 0%. Will apple replace my phone or fix my phone for free since its hardware problem and I have no money. This is my second iphone 5 replacement.

    My iPhone 5 dies at 20-24% it doesn't go all the way to 0%. Will apple replace my phone or fix my phone for free since its hardware problem and I have no money. This is my second iphone 5 replacement. I have no apple care so I'm worried. My phone has NEVER touched water! I only get 1/5 of battery use. I've also spent 30$ at the apple store on screen protectors for nothing! I really don't have 220$ nor 50$ I am on a strict budget. I believe I have to pay 220 not 50 ford a phone replacement for accidental damage. I don't know what category this falls under. I really need a new phone or battery. HELP! Will I have to pay? Also my screen lighting is all topsy-tervy every I put my screen on highest it won't work I have to wait about a minute? Forgot to mention that my apps exit out by themselves all the time when Im using them.

    So, have you tried a reset?  Restore from backup? Restore as new?  You seem to have a few problems but do not mention any action taken to resolve them.  What have screen protectors to do with anything?

Maybe you are looking for

  • Please suggest a correction in the code: Urgent

    I am capturing the Material Document No., Material No., Material Description, Quantity etc. into a main_table in my code so as to write/print labels containing GRN details (movement type '105') using se38. These labels are to be pasted on the materia

  • Updating iPhoto Library fails to complete in iPhoto '08

    I'm upgrading my mother's eMac from OS10.2 to OS10.5 (and iPhoto from 'really ancient, perhaps '04 if not earlier' to '08). The OS 10.5 upgrade appears to work '100%' but the iPhoto '08 hangs while attempting to Upgrade the photo library. The upgrade

  • Using iWeb to Publish to Google Sites

    Does anybody know if you can publish a site created with iWeb to Google Sites? I use me.com so i've never had the need for this and for anything else i use the iWeb FTP function. I have no experience with google Sites. I have a friend who cant afford

  • Getting error to access the JMS resouce.

    I have confabulated 4 managed servers (des1, des2,des3 and des4) with JMS servers in a cluster on WebLogic 9.2. The servers des1 and des2 are located on same host of admin server installed(e.g. the hostname is adminhost). The servers des3 and des4 ar

  • Why am I seeing a question mark sign when I click on safari to use the internet?

    why do I see a question mark sign after I click on safari to try to use the internet?