• 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
Re: New File Here
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New File Here


  • Subject: Re: New File Here
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 26 Oct 2012 18:30:48 -0500

On Oct 26, 2012, at 16:36, "koenig.yvan" <email@hidden> wrote:
Just a comment :
if it's not for your own use, I think that it would be fine to replace "Pick one" by "Pick one or more" because when the prompt say pick one it's not logical to guess that we may choose more.
______________________________________________________________________

Hey Yvan,

Good point.

I also changed the template folder initializer to create intermediate folders if necessary and to create a text-file-template.

--
Best Regards,
Chris

------------------------------------------------------------------------------------------------
#       Author: Christopher Stone <email@hidden>
#      Created: 2012-10-26 : 01:27
#     Modified: 2012-10-26 : 18:26
#  Application: Finder
#      Purpose: Create a new file from a file-type list in the front Finder window.
# Dependencies: Template files provided by the user.
------------------------------------------------------------------------------------------------

try

  

  try
    set templateFolderPath to ((path to application support from user domain as text) & "Script_Support:New_File_Here!:")
    set templateFolder to alias templateFolderPath
  on error
    set newFilesHereFolder to quoted form of (POSIX path of templateFolderPath)
    set textTemplate to newFilesHereFolder & "Text_Template.txt"
    do shell script "mkdir -p " & newFilesHereFolder & ";
     touch " & textTemplate & ";
     open -R " & textTemplate
    return
  end try

  

  tell application "Finder"
    if front window exists then
      set winTarget to target of front window as alias
      set fileTemplateList to name of files of templateFolder

      

      tell me to set fileType to choose from list fileTemplateList with title "New_File_Here! Templates" with prompt ¬
        "Pick One or More:" default items {get item 1 of fileTemplateList} with multiple selections allowed

      

      if fileType ≠ false then
        set AppleScript's text item delimiters to (return & templateFolderPath)
        set itemsToCopy to paragraphs of ((templateFolder as text) & fileType)

        

        repeat with i in itemsToCopy
          set i's contents to i as alias
        end repeat

        

        set copiedFiles to duplicate itemsToCopy to winTarget
        select copiedFiles
      end if

      

    else
      error "No windows open in Finder!"
    end if
  end tell

  

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

References: 
 >New File Here (From: Christopher Stone <email@hidden>)
 >Re: New File Here (From: "koenig.yvan" <email@hidden>)
 >Re: New File Here (From: Christopher Stone <email@hidden>)
 >Re: New File Here (From: "koenig.yvan" <email@hidden>)

  • Prev by Date: Re: Checking on the existence of a file
  • Next by Date: Re: Checking on the existence of a file
  • Previous by thread: Re: New File Here
  • Next by thread: Re: New File Here
  • Index(es):
    • Date
    • Thread