• 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 16:24:07 -0500

On Oct 26, 2012, at 03:23, koenig.yvan <email@hidden> wrote:
(1) Is it a good idea to create a new script relying upon list folder which is deprecated ?

(2) We may select several items in the choose file dialog but if we do that, the script fails with the error message :  the file "the:folder:New_File_Here! Templates:firstemplate.jpgsecondtemplate.tiff: is unavailable.
______________________________________________________________________

Hey Yvan,

Okay.  The error should be fixed.  Please give it another try.

Since I was using the Finder for several things anyway, I decided to do away with list folder.

Good feedback — thank you.

--
Best Regards,
Chris

------------------------------------------------------------------------------------------------
#       Author: Christopher Stone <email@hidden>
#      Created: 2012-10-26 : 01:27
#     Modified: 2012-10-26 : 16:17
#  Application: Finder 
#      Purpose: Create a new file from a file-type list in the front Finder window.
# Dependencies: Template files provided by the user.
#    Templates: Applescript, Text (so far)
------------------------------------------------------------------------------------------------

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 _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
      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:" 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
  return e
  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>)

  • Prev by Date: Re: New File Here
  • Next by Date: Re: New File Here
  • Previous by thread: Re: New File Here
  • Next by thread: Converting scripts to macros
  • Index(es):
    • Date
    • Thread