Simple AppleScript request

Discussion in 'Mac Programming' started by Wowzera, Aug 15, 2009.

  1. Wowzera macrumors 6502a

    Joined:
    Oct 14, 2008
    Location:
    Brazil
    #1
    Hello,

    I'm trying to create a script that will do the following:

    It may look a little complex, but it's related to simple terminal commands.
    The one I tried to do stuck on using the command "cd", I can't change the default location. :(
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    You look about 4 commands from a shell script that you could just call from an applescript. Just use "sleep 3" to pause, mkdir to create a directory, and mv to move a file.

    -Lee
     
  3. Wowzera thread starter macrumors 6502a

    Joined:
    Oct 14, 2008
    Location:
    Brazil
    #3
    Thanks for replying.
    The main goal is to find the Desktop/TEMP folder. Since I will not know the username (it will run on other machines).
    That perl scripts are a font things, I just edited it to make it simpler.
    I just have no idea on how to do that.
     
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    I don't know if this is TOTALLY safe, but "cd" or "cd ~" will take you to the user's home directory no matter what... getting to the desktop should just be "cd ~/Desktop", but it may be possible to move this.

    I don't know what you mean when you say the perl scripts are font things, so i'm not sure how to help you there.

    -Lee
     
  5. Wowzera thread starter macrumors 6502a

    Joined:
    Oct 14, 2008
    Location:
    Brazil
    #5
    Hello lee,

    Thanks for replying again.
    The perl scripts will be inside that TEMP folder. To execute them, all I need to do is type on the terminal window " perl scriptname.pl " and then the parameters for it.

    So the applescript I am requesting will be:

    cd to TEMP folder;
    run these terminal commands (with a pause between them);
    get the final file and move to a specified folder.
     
  6. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #6
    should just be:
    Code:
    cd ~/Desktop/TEMP
    perl random.pl --out-prefix=result-regular --in-file=file.tar
    sleep 3
    perl second.pl --out-prefix=result-different --in-file=file2.tar
    sleep 3
    perl last.pl --out-final=name.tar *.rar
    sleep 3
    rm *.zip
    rm *.rar
    rm *.rtf
    mkdir ~/Desktop/Name
    mv name.rar ~Desktop/Name
    
    -Lee
     
  7. Wowzera thread starter macrumors 6502a

    Joined:
    Oct 14, 2008
    Location:
    Brazil
    #7
    Thanks Lee.
    Sorry, but it does not compile on the Applescript :(
    As I have said, I'm total noob on it, I'm still reading lot of things but I didn't find any good examples to follow by far.
    Could you tell me how do I make it run?
     
  8. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #8
    Code:
    do shell script "cd ~/Desktop/TEMP
    perl random.pl --out-prefix=result-regular --in-file=file.tar
    sleep 3
    perl second.pl --out-prefix=result-different --in-file=file2.tar
    sleep 3
    perl last.pl --out-final=name.tar *.rar
    sleep 3
    rm *.zip
    rm *.rar
    rm *.rtf
    mkdir ~/Desktop/Name
    mv name.rar ~Desktop/Name"
    
    As stated, this is shell script. You might be able to do the same thing with "pure" applescript, but i have no idea how. This should run the shell script from an applescript.

    -Lee
     
  9. Wowzera thread starter macrumors 6502a

    Joined:
    Oct 14, 2008
    Location:
    Brazil
    #9
    I figured it out now, after reading thousand of topics around the google search results.
    Thank you so much for your kindness Lee :)
     

Share This Page