Apple script finder problem

Discussion in 'Mac Programming' started by Demphis, Oct 12, 2017.

  1. Demphis macrumors newbie

    Joined:
    Oct 12, 2017
    #1
    Hello, im trying to write a script that creates a folder and lets the user name it and choose location where to create it.
    My script:
    tell application "finder"
    set theFolder to make new folder at dekstop
    set theName to text returned of
    (display dialog "Folderio pavadinimas" default answer "")
    set loc to choose folder "Pasirinkite folderio lokacija"
    end tell
    Any solutions how to improve this program and make it work?
     
  2. kryten2, Oct 13, 2017
    Last edited: Oct 13, 2017

    kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    You can try this.

    Code:
    set theLoc to choose folder with prompt "Just testing"
    set theName to text returned of (display dialog "Enter the name of the folder to create: " default answer "Test")
    tell application "Finder"
       -- insert actions here
       if not (exists folder theName of theLoc) then
           set theFolder to make new folder at theLoc with properties {name:theName}
       end if
    end tell
    
    
    Note: Not at home and not tested. There's more than one way to get the result you need. Look at the Finder and Standard Additions Dictionaries.

    Info : The First Step
     

Share This Page