0

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 ?

0

1 Answer 1

1
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
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot ! Works fine ! It's possible to add a new line in this alert popup ? put the message on two lines ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.