Is this possible in AppleScript?

I'm working on a project that will require a new file to be uploaded to a directory on a server every day. I've written a nice little script that launches YummyFTP and overwrites the designated folder on the server with the contents of a nominated folder called "Upload" on my desktop containing 2 files (one.mov and one.txt). So far so good and it works fine.
Because I then have to change the contents of the folder daily, I have a "Pending" folder with 365 files that are named with a descriptive title eg. holiday.mov/holiday.txt, golf.mov/golf.txt etc.) The path is yada..yada../desktop/Upload/Pending
Is there a way to write a script that will automatically take the top 2 items from the "Pending" folder, rename them and move them to the nominated folder? Or maybe overwrite them based on the creation date. I figure that if they are identically named, they will always be adjacent.
Any help or tips appreciated.

There's actually no imperative whatsoever to pre-determine the order. In fact, it might be a bit more fun if no-one knows what today's .mov will be
Oh, then that's easy. Pick a file at random
Here's a starting script - define the source and destination directories at the top of the script. It then picks a file at random, strips off that file's extension and locates all other files in the directory that match that base name (e.g. if it finds 'snowboarding.txt' as the random file, it then strips '.txt' and finds all 'snowboarding*' files.
It then duplicates those files to the destination directory. I know your original post calls for it to rename the files, but I'm not sure what you want/expect to happen there. I'm sure its do-able, just need to know what you want.
set sourceDir to "HD:path:to:sourcefiles" -- path to source files
set destDir to "HD:path:to:uploadsdir" -- path to watched uploads folder
tell application "Finder"
  set theFile to (some file of folder sourceDir)
  set basename to my stripExtn(theFile)
  set files2Copy to every file of sourceDir whose name begins with basename
  duplicate files2Copy to folder destDir
end tell
on stripExtn(filename)
  set {n, e} to {name, name extension} of filename
  set b to characters 1 through -(2 + (length of e)) of n as text
  return b
end stripExtn

Similar Messages

  • Is this possible in AppleScript and if so how ?

    I am trying to make an app that opens AppleScript and types in things.  I then want the AppleScript that the other Applescript wrote to save as an application, and rename it.  Is this possible and if so, can you give me an example?

    If I'm following what you want, the applescript editor is fully scriptable.  In fact, there are a bunch of applescript samples in /Library/Scripts/Script Editor Scripts/ that show you how to use applescript to write and compile applescript code into a new window.  Just for a quick-and-dumb example:
    set the target_string to "X-X-X"
    set the script_text to "display dialog \"" & target_string & "\" buttons {\"OK\"} default button 1" & return
    set outputPath to POSIX path of (path to desktop folder from user domain) & "test.app"
    tell application "AppleScript Editor"
              activate
              set newDoc to make new document
              tell newDoc
                        set its text to script_text
                        try
                                  check syntax
                                  compile
                        end try
                        save in outputPath as "com.apple.application"
              end tell
    end tell

  • Is it possible for Applescript to know what link is selected in the Indesign Links Palette?

    Hi there,
    I've written some ApplesScripts for Indesign that act on all links, missing links and/or selected links, but what if I wanted to perform an action on a link that is only selected in the links palette?
    Is it possible for AppleScript to know which link is selected in the Indesign links palette?
    Regards,
    David

    Hi czigrand,
    Thanks for visiting Apple Support Communities.
    Currently, you can gift dollar amounts or individual items (EG. songs) on the iTunes Store. See this article for more information:
    In the iTunes Store, you can gift a dollar amount or specific music, movies, TV shows, or apps from your iPhone, iPod touch, iPad, Mac, or PC. Follow these steps to send a gift from the iTunes Store.
    iTunes: Sending iTunes Gifts
    http://support.apple.com/kb/HT2736
    Best Regards,
    Jeremy

  • I have two separate itune accounts under two different email accounts and would like to combine them under one account.  Is this possible and if so, how do I do it?

    I have two separate itune accounts under two different email accounts and would like to combine them under one account.  Is this possible and if so, how do I do it?

    If you go to Settings > iTunes & AppStore , you can sign out from your account, and sign in with the one you've used to purchase apps.This will not remove any apps you already have on it.
    Then you can go to AppStore and download apps you've purchased (either via "Purchased" button in "Updates", or simply search for them and download them.
    That way you can have multiple accounts' apps on your iPad. When updating, you will be prompted for the credentials for account you've purchased given App with.

  • I work with a child who is not able to move his neck.  to see the ipad, it has to be placed high above the table (eye level).  he needs access with a mouse - is this possible?

    I work with a child who has physical disability and cannot move his neck.  The ipad needs to be eyelevel in order for him to see it, but he also is not able to raise his hand and would need mouse access...  is this possible?

    I'm sorry but the iPad does not work with a mouse, there is no cursor on the iPad and the iPad was designed as a touch screen device so a mouse will not work.
    I really don't know what to suggest other than this new device, and it might be worth a look. I assume that the child can use his hands for a keyboard.
    http://www.thinkgeek.com/product/e722/

  • Unfortunately, I lost by an update all the apps on my iPad 2. Now I can not pull the data from the cloud to my iPad. How is this possible?

    Unfortunately, I lost by an update all the apps on my iPad 2. Now I can not pull the data from the cloud to my iPad. How is this possible?

    If you just installed iCloud does that mean you updated the iOS that's running on your iPad?  If so, you'll want to restore all the programs you have from the backup you hopefully made.
    Refer to these articles for help.
    iTunes: Backing up, updating, and restoring iOS software.
    If you don't want to use iCloud, simply don't activate it.
    You can also download the programs again.
    If you live in a country that supports re-downloading apps then you can re-download them.  You can refer to this article for more help.
    Downloading past purchases from the App Store and iTunes Store
    What to know if your country supports downloading past purchases?
    iTunes in the Cloud Availability

  • I am getting old and looking forward to use I Pad as a Phone if possible through WIFI! I this possible? The screen is to small for me! If possible, with new I Watch taking calls, other uses through I Pad!

    Like I wrote on title, I am getting old and it is not easy to see E-mails, news etc. on a I phone! New I phone will not help me for the size.
    If possible, everything without calls, I would like to use I Pad as direct unit, and for calls through I Pad over WIFI all calls. If a call as Skype, I would like
    to use the I Pad as a monitor. Is this possible?
    I found on a side that there is a product for people for better hearing, which can be put into the ears, using WIFI with I Phone.
    If this product could be used also for I Pad as a Phone for hearing, and the I watch or I Pad as Microphone, it will be great for old Mac users.
    Is this possible with our system know?
    I am using Mac since Classic II! Would like to continue with the newest items with the possibility for old person with bad Eyes or Ears.
    Looking forward for a kind answer
    with regards
    Christian an old Mac user!

    Definitely No

  • I have a Macbook Pro with OS 10.6.8 with no updates. Bundled is iPhoto 11, version 9.2.6. I would like to update my OS to 10.9.5 or later. Is this possible and which version is recommended?

    I have a MacBookPro with OS 10.6.8. It has no updates. This version contains Iphoto 11, version 9.2.3. I would like to upgrade my operating system to 10.9.5 or later. Is this possible and how best to proceed? How will this affect iPhoto?
    Thanks, Jeff

    If you have a mid/late 2007 MBP you can install the latest OSX that is available, on your MBP.  Mavericks (10.9) has been replaced by Yosemite (10.10) and is no longer available in the App store. 
    You choices are Lion (10.7), Mt.Lion (01.8) (both $20) or Yosemite (free).  The first two are available from the Apple online web site.  Yosemite can be downloaded from the App store.
    Ciao.

  • I just bought my macbook pro and it's charged up to 100% and is still plugged in but now shows the battery at 98%.  How is this possible when it's plugged in to the charger and the green light is on?

    I just bought my macbook pro and it's charged up to 100% and is still plugged in but now shows the battery at 98%.  How is this possible when it's plugged in to the charger and the green light is on?

    The system regularly lets the battery drop to about 95% when on the charger, then recharges to 100%.  This lets the batery exercise "just a little" all of the time and saves the recharge curcuits from overuse.
    Regualr occurence for me.
    Also ... you need to let your battery work at least once per month.  Let it run down to 40%, but not less if you can at all avoid it.  Running thr battery fully dead will shorten the battery life significantly.

  • Using one ipod on 2 computers - is this possible?!

    Hi guys I would really appreciate it if somebody could help out with this:
    I want to buy my girlfriend an 80gb Ipod Classic for xmas and load it with some music using my existing version of itunes (version 7.3.2.6) and then give it to her so that she can use the ipod with the verison of itunes that it comes with or she downloads. *This music will NOT be music purchased from itunes.*
    Is this possible? When her friend connects her new nano to my girlfriends pc and tries to use my girlfriends slightly older version of itunes all of the songs are greyed out and not useable.
    I do not want to buy the ipod and load it up only to find she can then not use it with her version of itunes.
    If anyone is certain about this i'd be greatly appreciative of an answer.
    David

    To change it back to automatically syncing you remove the check mark from "Manually manage songs and videos" and press Apply. If you don't want to use it as file storage device and want it to automatically eject when it is finished updating you also remove the check mark from "enable disk use" (this is checked by default when you set the iPod to update manually. Remember though that if you go back to updating automatically, any songs on the iPod that aren't in iTunes will be removed. You can't "sync" that is automatically update an iPod from multiple libraries or computers: Loading songs onto iPod automatically - Windows

  • How do I connect  Apple 20" Cinema Display to orignal MacBook Air which does not have a Fire-Wire port. Is this possible? Any advice would be appreciated. I have the Micro-DVI to DVI adapter. Norm

    I Wish to connect my 6 year old Apple 20" Cinema Display to an orignal MacBook Air which does not have a Fire-Wire port. Is this possible? Any advice would be appreciated. I have the Micro-DVI to DVI adapter. Norm

    The FireWire cable is just for the FireWire ports on the display.  The display will run without it.

  • I want to buy a Ipod Nano 16gb and it says it holds up to 4,000 songs, and 16 hours of video but on my Itunes I have 2,593 songs and it says I have 19.88 gb. How is this possible?

    I want to buy a Ipod Nano 16gb that says it holds up to 4,000 songs, 16 hours of video, and 14,000 pictures. On my Itunes Library, I have 2,593 songs and it says I have 19.88 gb just of songs. How is this possible? If I buy the Nano, will I not be able to have all my songs on the ipod? The music is my first and only prioarity. I want to be able to have up to at least 3,000 songs, even if that means not having video or pictures. Can someone please help me?

    Daniella04 wrote:
    I want to buy a Ipod Nano 16gb that says it holds up to 4,000 songs, 16 hours of video, and 14,000 pictures. On my Itunes Library, I have 2,593 songs and it says I have 19.88 gb just of songs. How is this possible? If I buy the Nano, will I not be able to have all my songs on the ipod? The music is my first and only prioarity. I want to be able to have up to at least 3,000 songs, even if that means not having video or pictures. Can someone please help me?
    Daniella,
    The estimated song capacities, such as 4000 songs in 16 GB, are based on 4 minute songs of 4 MB each, which is what you get at 128 encoding. 
    Most of us nowadays use well above 128.  (For example, the iTunes Store and Amazon MP3 both sell songs only in 256.)
    However, you can still make more songs fit!  When you sync your iPod, use the option to "convert higher bit rate songs," as pictured.  Choose 128.  This fits more on the iPod, but does not change the songs in your library.

  • I would like to access both my iTunes and my husbands iTunes on the same computer.  However, we still want our separate logins for our devices (iPad, 2 iPhones) for purchases.  Is this possible?

    Is there a way to have one computer hold both my iTunes account and my husbands iTunes account at the same time.  We do not want to log in and out, but want to be able to access both purchases on the same computer (songs, movies, etc).  However, we want to keep our accounts seperate for purchases on our devices.  Is this possible?

    How to use multiple iPods, iPads, or iPhones with one computer

  • There is no space to store video on my computer.  I am am looking at getting 1 terabyte on the cloud in hope i can edit video off of the cloud the same way I can with a hard drive.  Is this possible?

    There is no space to store video on my computer.  I am am looking at getting 1 terabyte on the cloud in hope i can edit video off of the cloud the same way I can with a hard drive.  Is this possible?

    Buy another hard drive.  They're cheap these days.
    In fact, buy a couple of 'em.  I recommend a minimum of five internal hard drives.
    C: Windows and Programs
    D: Project, graphic and audio files
    E: Cache and Scratch
    F: Media
    G: Export

  • HT204053 I have 4 iphones on the same Apple ID, but would like 4 different accounts and iCloud is this possible?

    I have 4 iphones on the same Apple ID, but would like 4 different accounts and iCloud is this possible?

    Create a new Apple ID for the one you want to change.

Maybe you are looking for

  • How to connect to HD TV after upgrade to OS 10.8.2

    How can I connect to my Sony HD TV after upgrade to OS 10.8.2? It worked before I upgraded and now it doesn't recognize the TV in the Display Pref.

  • Editing multiple CMYK objects inconsistency

    I'm hoping someone with more knowledge of Illustrator can help me figure something out. I know this is not the ideal way of making an adjustment to colors (e.g. should be done through the Edit > Edit Colors... menu) however this is driving me crazy t

  • Upgrading photoshop

    I have the full version of photoshop 6 for Mac, I upgraded to Photoshop 7 ....CS2....CS3...CS4  I originally installed photoshop 6 on a Powermac G4  OS9  gradually through CS2, CS3,  CS4 on OS X   1,2,3,4,5 and meanwhile migrated the software to a Ma

  • PI7.0 Material details

    Hi ...Frnds, Could you  please provide the material details for PI 7.0 TechEd.

  • Starting JVM Tool Interface agents in the VM during live phase

    The JVM Tool Interface(JVMTI) specification says that the JVMTI agents can be started in the VM during live phase but they havent mentioned how it can be done. Has anyone tried this before or got any hints on how to do it?