0
votes

I've created an AppleScript that have for function to create a folder in the place where i want, then place in this folder many empty text files.

I would like to know how to make at the end of the execution of this script, a window appears saying that the script is execute correctly and asking me if I want to display the folder in the Finder with a simple button.

My script :

set folderName to text returned of (display dialog "Please enter the folder name:" default answer "Folder_Name")
set loc to choose folder "Choose Parent Folder Location"

tell application "Finder"
    set newfolder to make new folder at loc with properties {name:folderName}
    make new file at newfolder with properties {name:"fileA.txt"}
    make new file at newfolder with properties {name:"fileB.txt"}
    make new file at newfolder with properties {name:"fileC.txt"}
end tell

it is possible ?

So, if it's possible, could you help me please ?

1

1 Answers

1
votes
set folderName to text returned of (display dialog "Please enter the folder name:" default answer "Folder_Name")
set loc to choose folder "Choose Parent Folder Location"

try
    tell application "Finder"
        set newfolder to make new folder at loc with properties {name:folderName}
        make new file at newfolder with properties {name:"fileA.txt"}
        make new file at newfolder with properties {name:"fileB.txt"}
        make new file at newfolder with properties {name:"fileC.txt"}
    end tell

    display dialog "Script executed correctly. Reveal Folder" buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel"
    if button returned of the result = "OK" then
        tell application "Finder"
            reveal newfolder
            activate
        end tell
    end if
end try