-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathNew Text File Here.applescript
57 lines (48 loc) · 1.81 KB
/
New Text File Here.applescript
1
#New Text File Here AppleScript#2018 (ɔ) jraulc at gmail dot comset localeString to user locale of (get system info)#you can localize to your language hereif localeString starts with "es" then #button labels set okButton to "Aceptar" set cancelButton to "Cancelar" set txtButton to "Usar .txt" set NoTxtButton to "Sin .txt" #labels and dialogs set inFileNameStr to "Por favor ingrese el nombre del archivo:" set askFileExtStr to "Usted quiere crear el archivo: " set noExtStr to "Sin una extencion '.txt'?" else #default if not match with the localized language #button labels set okButton to "Acept" set cancelButton to "Cancel" set txtButton to "Use .txt" set NoTxtButton to "No .txt" #labels and dialogs set inFileNameStr to "Please input the file name:" set askFileExtStr to "Do you want to create the file: " set noExtStr to "Without a .txt extension?"end iftell application "Finder" set the currentFolder to (folder of the front window as alias) try set selectedItem to (item 1 of (get selection)) set fileName to displayed name of selectedItem as string on error set fileName to name of (folder of the front window as alias) as string end try set fullFileName to fileName & ".txt" set createTextFile to choose file name with prompt inFileNameStr ¬ default name fullFileName default location currentFolder set newFile to POSIX path of createTextFile if newFile does not end with ".txt" then set askFileExt to display alert askFileExtStr & (POSIX path of createTextFile) ¬ message noExtStr as critical buttons {txtButton, NoTxtButton} default button 2 set fileExt to button returned of askFileExt if fileExt is equal to txtButton then set newFile to newFile & ".txt" end if end if do shell script "touch \"" & newFile & "\"" do shell script "open \"" & newFile & "\"" end tell