Data arranged in columns

Hi there!

I want to improve my script to display my data in Textedit arranged in columns.

Actually my script read the characteristics of the photoshop’s files in the folder I choose and this is my output:

Is there a way to obtain this output:

This is my script:

close application "Image Events"
set y to (choose folder)
set myListAss to ""

tell application "Finder" to set the source_folder to y as alias
set the item_list to list folder source_folder without invisibles
set source_folder to source_folder as string
repeat with i from 1 to number of items in the item_list
	set x to item i of the item_list
	set x to (source_folder & x) as alias
	tell application "Image Events"
		set theImage to open x as alias
		set myName to the name of theImage
		set imgInfo to dimensions of theImage
		set mywidth to item 1 of imgInfo
		set myheight to item 2 of imgInfo
		set myfiletype to file type of theImage
		set imgres to resolution of theImage
		set myresolutionX to item 1 of imgres
		set myresolutionY to item 2 of imgres
		set mycolorspace to color space of theImage
		set mydeepimage to bit depth of theImage
		close theImage
	end tell
	set myListRel to myName & tab & tab & mywidth & tab & myheight & tab & myfiletype & tab & myresolutionX & tab & myresolutionY & tab & mycolorspace & tab & return
	set myListAss to myListAss & myListRel
end repeat
set valore to text of myListAss

tell application "TextEdit"
	activate
	set myDocument to make document
	tell myDocument
		set myTestata to "Nome" & tab & tab & "Base px" & tab & "Altezza px" & tab & "Formato" & tab & "RisoluzioneX" & tab & "RisoluzioneY" & tab & "Spazio Colore" & tab
		set myTesto to valore
		set its text to myTestata & return & myTesto
		set font of every character of its text to "Verdana"
		set font of every character of first paragraph of its text to "Verdana-Bold"
	end tell
end tell

Model: MacBook Pro
AppleScript: 2.0.1
Browser: Safari 531.9
Operating System: Mac OS X (10.6)

Hi,

the tab positions are not scriptable in TextEdit.
Maybe you could create an empty template with your desired tab positions

This is not perfect but it may give you something to play around with. You could also write an AppleScript pad handler to do the same thing as the ruby script.


close application "Image Events"
set y to (choose folder)
set imageAttributes to ""

tell application "Finder" to set the source_folder to y as alias
set the item_list to list folder source_folder without invisibles
set source_folder to source_folder as string
repeat with i from 1 to number of items in the item_list
	set x to item i of the item_list
	set x to (source_folder & x) as alias
	tell application "Image Events"
		set theImage to open x as alias
		set myName to the name of theImage
		set imgInfo to dimensions of theImage
		set mywidth to item 1 of imgInfo
		set myheight to item 2 of imgInfo
		set myfiletype to file type of theImage
		set imgres to resolution of theImage
		set myresolutionX to item 1 of imgres
		set myresolutionY to item 2 of imgres
		set mycolorspace to color space of theImage
		set mydeepimage to bit depth of theImage
		close theImage
	end tell
	set imageAttributes to imageAttributes & quoted form of (myName & "," & mywidth & "," & myheight & "," & myfiletype & "," & myresolutionX & "," & myresolutionY & "," & mycolorspace & "<>")
end repeat

set valore to do shell script "/usr/bin/ruby ~/desktop/text_aligner.rb " & imageAttributes

tell application "TextEdit"
	activate
	set myDocument to make document
	tell myDocument
		set myTestata to "Nome" & tab & tab & "Base px" & tab & "Altezza px" & tab & "Formato" & tab & "RisoluzioneX" & tab & "RisoluzioneY" & tab & "Spazio Colore" & tab
		set myTesto to valore
		set its text to myTestata & return & myTesto
		set font of every character of its text to "Verdana"
		set font of every character of first paragraph of its text to "Verdana-Bold"
	end tell
end tell

Save this ruby script on your desktop as “text_aligner.rb”

Since you are on Snow Leopard, why not make an AppleScriptObjC application for this.
Assuming this is just for you and not for distribution to others with os’s less than 10.6.
It would be fairly trivial and easy to read in a table. Just a thought. :slight_smile:

@StefanK
Thanks for your reply. Actually I feared this answer.

@Craig Williams
Thank for your suggestion. I’ll play around with it soon.
P.S. I’m not on Snow Leopard

From your first post:

Model: MacBook Pro
AppleScript: 2.0.1
Browser: Safari 531.9
Operating System: Mac OS X (10.6)
Paolo

That is why I thought you were on Snow Leopard.

Craig

I am sorry about that.
It was the automatic answer suggested for the field.

Thank you very much!

Paolo