• 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: File-Info as Text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File-Info as Text


  • Subject: Re: File-Info as Text
  • From: Christopher Stone <email@hidden>
  • Date: Mon, 18 Aug 2014 19:33:59 -0500

On Aug 18, 2014, at 00:25, Shane Stanley <email@hidden> wrote:
Anyway, here's a script library that returns quite a bit more info. It returns it either as a text version of a property list, or if you have ASObjCExtras.framework installed, as a record. All it needs is someone like Chris to format the result nicely...
______________________________________________________________________

Hey Shane,

That's on the order of TMI.  ;-)

But then it's easy to parse for the data you want.

Okay here's a script using your library that cleans up the text a bit using BBEdit ( just to be different and NOT suck of course :). [1]

For those who don't know - BBEdit and TextWrangler can AppleScript find/replace within a given string and not just within a specific document.  (As of several versions back of 10.5.11.)

I've stripped some characters out of Shane's result and made it into a table of sorts.

I find it a bit more readable, but YMMV.  I have not examined the output with a microscope, so there may be a bobble or two.  If you find one let me know, and I'll fix it.

--
Best Regards,
Chris

[1] TextWrangler will work equally well as a free alternative.

-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2014/08/18 18:00
# dMod: 2014/08/18 19:23
# Appl: BBEdit
# Task: Use Shane's Library to get file-info and sending it to BBEdit
# Libs: Shane Stanley's File-Info Library
# Osax: None
# Tags: @Applescript, @Script, @File, @Info, @Shane, @Library
-------------------------------------------------------------------------------------------

use ZOSA : script "z_osa"
use scripting additions

-------------------------------------------------------------------------------------------
tell application "Finder"
  set fileAlias to first item of (selection as alias list)
  set fileName to name of fileAlias
end tell
set fileInfoText to ZOSA's moreInfoFor:(POSIX path of fileAlias) dirSizes:false
tell application "BBEdit"
  activate
  set processedText to replace " *[{}(),;] *" using "" searchingString fileInfoText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to replace "^ {4}" using "" searchingString processedText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to replace "\\A\\s+|\\s+\\Z" using "" searchingString processedText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to replace "\\b(kMDItem(FS)?|UT|CFBundle|NSURL)" using "" searchingString processedText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to replace " " using " " searchingString processedText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to replace "(?-i)([[:lower:]])([[:upper:]])" using "\\1 \\2" searchingString processedText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to replace "file://" using "" searchingString processedText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to replace " *= *" using "\\t:\\t" searchingString processedText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to replace "\"" using "" searchingString processedText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to replace "(\\.app)/$" using "\\1" searchingString processedText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to replace "\\x0D" using "\\x0A" searchingString processedText options {case sensitive:false, search mode:grep, starting at top:true}
  set processedText to processedText & linefeed
  set processedText to do shell script "column -t -s'" & tab & "' <<< " & quoted form of processedText without altering line endings

  

  set newDoc to make new document with properties {name:"File-Info for » " & fileName, text:processedText, bounds:{0, 44, 1615, 1196}}
  select insertion point before character 1 of newDoc's text

  

end tell

-------------------------------------------------------------------------------------------
--» HANDLERS
-------------------------------------------------------------------------------------------
--  I have a bunch of BBEdit Handlers in a library for easy one-liners in various scripts.
on bbeditNewDoc(_text, _activate)
  tell application "BBEdit"
    set newDoc to make new document with properties {text:_text, bounds:{0, 44, 1920, 1200}}
    tell newDoc
      select insertion point before its text
    end tell
    if _activate = true or _activate = 1 then activate
  end tell
end bbeditNewDoc
-------------------------------------------------------------------------------------------

 _______________________________________________
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: File-Info as Text
      • From: Shane Stanley <email@hidden>
References: 
 >File-Info as Text (From: Christopher Stone <email@hidden>)
 >Re: File-Info as Text (From: Shane Stanley <email@hidden>)

  • Prev by Date: Background Printing
  • Next by Date: Re: File-Info as Text
  • Previous by thread: Re: File-Info as Text
  • Next by thread: Re: File-Info as Text
  • Index(es):
    • Date
    • Thread