For a while now I've been meaning to write a file-info script to grab the info I want as text and make it easy to grab any of the bits I want.
I've had keyboard-driven scripts to put the alias, or relative alias, or posix path(s) of of the Finder selection on the clipboard for well over a decade, but sometimes it's nice to have the whole enchilada to choose from.
I often want a file's creation or modification date in the 2nd form below.
I often want the Bundle ID of an app.
Sometimes I want other stuff, and I don't want to have to click, click, click in the Finder's Get-Info window.
It could probably be more efficient, but it's working - and I'm throwing it into the wild.
[1] TextWrangler: BBEdit's freeware sibling.
-------------------------------------------------------------------------------------------
Name : Script Debugger.app
Path HFS : Ryoko:Users:chris:Downloads:Script Debugger.app
Path HFS Relative : ((path to downloads folder as text) & "Script Debugger.app")
Path Posix : /Users/chris/Downloads/Script Debugger.app/
Path Posix-Home : ~/Downloads/Script Debugger.app/
Creation Date : Monday, June 30, 2014 at 15:38:36 CDT » 2014/06/30 15:38:36
Modification Date : Friday, July 25, 2014 at 02:46:31 CDT » 2014/07/25 02:46:31
Size : 37662425
Folder : true
Alias : false
Package Folder : true
Visible : true
Extension Hidden : true
Name Extension : app
Displayed Name : Script Debugger.app
Short Name : Script Debugger
Default Application : Ryoko:Users:chris:Downloads:Script Debugger.app
Kind : Application
Short Version : 6.0
Long Version : missing value
Bundle Identifier : com.latenightsw.ScriptDebugger6
File Type : APPL
File Creator : asDB
Type Identifier : com.apple.application-bundle
Busy Status : false
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2014/08/15 20:04
# dMod: 2014/08/15 21:41
# Appl: Finder, BBEdit
# Task: Send Info for the selected item as text to BBEdit
# Tags: @Applescript, @Script, @Finder, @BBEdit, @File-Info, @Information
# Note: Tested only on OSX 10.9.4
-------------------------------------------------------------------------------------------
tell application "Finder"
set fSel to selection as alias list
if fSel ≠ {} then
set fileAlias to first item of fSel
end if
end tell
set itemInfo to info for fileAlias
set dCre to strftime (creation date of itemInfo) into "%Y/%m/%d %H:%M:%S"
set dMod to strftime (modification date of itemInfo) into "%Y/%m/%d %H:%M:%S"
set displayName to "File-Info » " & (name of itemInfo)
set hfsPath to ("Path HFS : " & fileAlias as text) & linefeed
set relativeHFSPath to "Path HFS Relative : " & makeRelativeAlias(fileAlias) & linefeed
set posixPath to "Path Posix : " & POSIX path of fileAlias & linefeed
set tildePath to change (POSIX path of (path to home folder)) into "~/" in posixPath
if tildePath ≠ posixPath then
set tildePath to change "(Posix)" into "\\1-Home" in tildePath with regexp else
set tildePath to ""
end if
try
itemInfo / 0
on error e
# e
set e to change "\\x{00}" into
"" in
e with regexp
without case sensitive
set e to change "\\r" into
"\\n" in
e with regexp
without case sensitive
set e to change "\", " into
"\\n" in
e with regexp
without case sensitive
set e to change "(true|false), " into
"\\1\\n" in
e with regexp
without case sensitive
set e to change ", (folder:(?:true|false))" into "\\n\\1" in e with regexp without case sensitive set e to change "(date:)date " into
"\\1" in
e with regexp
without case sensitive
set e to change "alias " into "" in e with regexp without case sensitive
set e to change "(missing value), " into
"\\1\\n" in
e with regexp
without case sensitive
set e to change "(folder window:{\\d+, \\d+, \\d+, \\d+}), " into "\\1\\n" in e with regexp without case sensitive set e to change "^([^:]+)(:)" into
"\\1\\t\\2\\t" in
e with regexp
without case sensitive
set e to change "\"" into "" in e with regexp without case sensitive
set e to change "(^Creation Date.+)" into
"\\1" & " » " & dCre in
e with regexp
without case sensitive
set e to change "(^Modification Date.+)" into "\\1" & " » " & dMod in e with regexp without case sensitive set e
to change "(\\A.+\\n)" into "\\1" & hfsPath
& relativeHFSPath
& posixPath
& tildePath
in e
with regexp without case sensitive set e to change "(\\.app):(\"\\))?$" into
"\\1\\2" in
e with regexp
without case sensitive
set e to do shell script "column -t -s' ' <<< " & quoted form of e without altering line endings
set e to change "^(\\w)" into
"\\u\\1" in
e with regexp
without case sensitive
set dateSpacer to {matchLen of item 1, matchLen of item 2} of (find text "^.+»" in e with regexp and all occurrences without case sensitive)
set dateSpacer to (maximum of (statlist dateSpacer)) as integer
set e to change "»" into " »" in e with regexp without case sensitive
set e to change "^(.{" & dateSpacer & "}) +»" into "\\1» " in e with regexp without case sensitive
set e to linefeed & e # For neater display in Script Debugger or the Applescript Editor
end try
-------------------------------------------------------------------------------------------
set e to change "^\\s+" into "" in e with regexp without case sensitive # For neater display in BBEdit
tell application "BBEdit"
activate
make new document with properties {name:displayName, bounds:{203, 44, 1717, 1196}, text:e}
end tell
------------------------------------------------------------------------------------------------
--» HANLDERS
-------------------------------------------------------------------------------------------
on makeRelativeAlias(_item)
set pathToSpec to {application support, applications folder, desktop, desktop pictures folder, documents folder, downloads folder, favorites folder, Folder Action scripts, fonts, help, home folder, internet plugins, keychain folder, library folder, modem scripts, movies folder, music folder, pictures folder, preferences, printer descriptions, public folder, scripting additions folder, scripts folder, shared documents, shared libraries, sites folder, startup disk, startup items, system folder, system preferences, temporary items, trash, users folder, utilities folder, workflows folder}
set expandedPathTo to {}
repeat with i in pathToSpec
set end of expandedPathTo to path to (get contents of i) from user domain
end repeat
set AppleScript's text item delimiters to linefeed
set expandedPathTo to paragraphs of (expandedPathTo as text)
set AppleScript's text item delimiters to ":"
set _item to _item as text
set _len to (length of (text items of _item))
repeat with i from _len to 1 by -1
set _path to ((text items 1 thru i of _item) as text) & ":"
if _path is in expandedPathTo then
repeat with idx from 1 to (length of expandedPathTo)
if (item idx of expandedPathTo) = _path then
set refFldr to "path to " & (item idx of pathToSpec) as text
set diskLocalRef to (("(" & "(" & refFldr & " as text) & ") & "\"" & (text items (i + 1) thru -1 of _item) as text) & "\")"
try
run script diskLocalRef
on error
set refFldr to refFldr & " from user domain"
set diskLocalRef to ("alias " & ("(" & "(" & refFldr & " as text) & ") & "\"" & (text items (i + 1) thru -1 of _item) as text) & "\")"
try
run script diskLocalRef
on error e
error e
end try
end try
return diskLocalRef
end if
end repeat
end if
end repeat
end makeRelativeAlias
------------------------------------------------------------------------------------------------