applescript Copying the same ~40 files to folder in SPECIFIC order 10000+ times

Discussion in 'Mac Programming' started by amanases, Jan 17, 2015.

  1. amanases, Jan 17, 2015
    Last edited by a moderator: Jan 18, 2015

    amanases macrumors newbie

    Joined:
    Jan 17, 2015
    Location:
    Wichita Falls
    #1
    Ive done a little basic programming a long time ago, 10+ years ago and have forgotten most of it now, but that was in C++.

    What i need is a program to basically do this:

    for each and every character in string or text file
    depending on the character in string, copy this specific file to this folder and keep both files when the name is the same.

    i need it to read the string/text like normal, from left to right and top to bottom if it it read from text file

    i need to copy the same ~40 files (pictures ~250KB each) to a folder in a Specific order thousands and thousands of times.


    this is what i got and i'm lost right now.

    Code:
    set theText to "This is some text that i need a specific file copied depending on the character in this string"
    
    if character 1 of theText = "T" then say "it worked"
    

    i know what i need to make it work but all my programming knowledge has vanished. so im starting learning over again.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    This would be easier to understand if you posted an example of the data, then described what should happen as a result of that data.

    For example:
    If the text file contains:
    Code:
    abc
    xy
    the program should copy the following files:
    Code:
    image-a.jpg
    image-b.jpg
    image-c.jpg
    image-x.jpg
    image-y.jpg
    from the folder "Photos" located in my home folder, to a folder "Plugh" located on an attached USB flash drive named "Plover".
    The original file should be left in place if the character is from a to p. If it's q thru z, the original file should be removed after copying.
    The above example is completely fabricated, because I honestly can't figure out what you want to happen based on your description. If no one else can figure out what should happen, then no one can advise you on how to make it happen.

    All programming eventually boils down to making a clear and accurate explanation of what should happen. Right now, we need an English explanation, with enough detail that someone can follow your directions and accomplish the task by hand. Once that explanation is clear, the next step will be to translate that into computer code. But without a clear understandable plain-English explanation, it will be impossible to code.
     
  3. amanases, Jan 17, 2015
    Last edited by a moderator: Jan 18, 2015

    amanases thread starter macrumors newbie

    Joined:
    Jan 17, 2015
    Location:
    Wichita Falls
    #3
    i think it would look something like this

    i think it would look something like this

    Code:
    
    #letter pictures
    set lettera to Users/timothynorris/desktop/logos/a.jpg
    set letterb to Users/timothynorris/desktop/logos/b.jpg
    set letterc to Users/timothynorris/desktop/logos/c.jpg
    set letterd to Users/timothynorris/desktop/logos/d.jpg
    set lettere to Users/timothynorris/desktop/logos/e.jpg
    set letterf to Users/timothynorris/desktop/logos/f.jpg
    set letterg to Users/timothynorris/desktop/logos/g.jpg
    set letterh to Users/timothynorris/desktop/logos/h.jpg
    set letteri to Users/timothynorris/desktop/logos/i.jpg
    set letterj to Users/timothynorris/desktop/logos/j.jpg
    set letterk to Users/timothynorris/desktop/logos/k.jpg
    set letterl to Users/timothynorris/desktop/logos/l.jpg
    set letterm to Users/timothynorris/desktop/logos/m.jpg
    set lettern to Users/timothynorris/desktop/logos/n.jpg
    set lettero to Users/timothynorris/desktop/logos/o.jpg
    set letterp to Users/timothynorris/desktop/logos/p.jpg
    set letterq to Users/timothynorris/desktop/logos/q.jpg
    set letterr to Users/timothynorris/desktop/logos/r.jpg
    set letters to Users/timothynorris/desktop/logos/s.jpg
    set lettert to Users/timothynorris/desktop/logos/t.jpg
    set letteru to Users/timothynorris/desktop/logos/u.jpg
    set letterv to Users/timothynorris/desktop/logos/v.jpg
    set letterw to Users/timothynorris/desktop/logos/w.jpg
    set letterx to Users/timothynorris/desktop/logos/x.jpg
    set lettery to Users/timothynorris/desktop/logos/y.jpg
    set letterz to Users/timothynorris/desktop/logos/z.jpg
    
    
    
    #number pictures
    set numberzero to Users/timothynorris/desktop/logos/zero.jpg
    set numberone to Users/timothynorris/desktop/logos/one.jpg
    set numbertwo to Users/timothynorris/desktop/logos/two.jpg
    set numberthree to Users/timothynorris/desktop/logos/three.jpg
    set numberfour to Users/timothynorris/desktop/logos/four.jpg
    set numberfive to Users/timothynorris/desktop/logos/five.jpg
    set numbersix to Users/timothynorris/desktop/logos/six.jpg
    set numberseven to Users/timothynorris/desktop/logos/seven.jpg
    set numbereight to Users/timothynorris/desktop/logos/eight.jpg
    set numbernine to Users/timothynorris/desktop/logos/nine.jpg
    
    #punctuation pictures
    set punctuationperiod to Users/timothynorris/desktop/logos/period.jpg
    set punctuationspacebar to Users/timothynorris/desktop/logos/spacebar.jpg
    set punctuationquotation to Users/timothynorris/desktop/logos/quotation.jpg
    set punctuationparenthesis to Users/timothynorris/desktop/logos/parenthesis.jpg
    
    set destinationfolder to Users/timothynorris/Desktop/putpictureshere
    
    
    set theText to "This is paragraph 1 of some text. This is paragraph 2 of some text."
    
    get character 1 of theText
    what is character 1 of theText
    
    get character 2 of theText
    what is character 2 of theText
    
    get character 3 of theText
    what is character 3 of theText
    
    etc...
    
    if character equals “a” then copy lettera to destinationfolder
    if character equals “b” then copy letterb to destinationfolder
    if character equals “c” then copy letterc to destinationfolder
    if character equals “.” then copy punctuationperiod to destinationfolder
    if character equals “0” then copy numberzero to destinationfolder
    if character equals “ ” then copy punctuationspacebar to destination folder
    
    etc…
    i need it to do this for thousands and thousands of letters of which i will specify in theText variable once it works
     

Share This Page