------------------------------------------------------------------------------------------------
# Author: ccs
# Created: 2012-10-26 : 01:27
# Modified: 2012-10-26 : 01:40
# Application: Finder
# Purpose: Create a new file from a file-type list in the front Finder window.
# Dependencies: None
------------------------------------------------------------------------------------------------
try
try
set templateFolder to ((path to application support from user domain as text) & "Script_Support:New_File_Here!:")
set templateFolder to alias templateFolder
on error
set _temp to quoted form of (POSIX path of templateFolder)
do shell script "mkdir " & _temp & "; open -R " & _temp
return
end try
tell application "Finder"
if front window exists then
set winTarget to target of front window as alias
else
error "No windows open in Finder!"
end if
end tell
set fileTemplateList to list folder templateFolder
set fileType to choose from list fileTemplateList with title "New_File_Here! Templates" with prompt ¬
"Pick One:" default items {get item 1 of fileTemplateList} with multiple selections allowed
if fileType ≠ false then
set _file to alias ((templateFolder as text) & fileType)
tell application "Finder"
duplicate _file to winTarget
select ((winTarget as text) & fileType)
end tell
end if
on error e number n
set e to e & return & return & "Num: " & n
tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then set the clipboard to e
end try
------------------------------------------------------------------------------------------------