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