• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
New File Here
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New File Here


  • Subject: New File Here
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 26 Oct 2012 02:06:12 -0500

Hey Folks,

There are a few utilities out there to create a new file of a specific file-type in the front directory in the Finder.

Today I needed something like that, so I wrote a simple one.

You just create templates of any desired file-type in the New_File_Here! folder (the script will create it if it doesn't exist and reveal it in the Finder).

You get a choose-from dialog with the file templates and can go to town from there.

Multiple selections are supported.

I chose to select the newly created file in the Finder for renaming rather than fooling with another Applescript dialog.

--
Best Regards,
Chris

------------------------------------------------------------------------------------------------
#       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

------------------------------------------------------------------------------------------------

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: New File Here
      • From: "koenig.yvan" <email@hidden>
  • Prev by Date: Re: HFS Path by Reference
  • Next by Date: Re: New File Here
  • Previous by thread: Re: HFS Path by Reference
  • Next by thread: Re: New File Here
  • Index(es):
    • Date
    • Thread