Newbie want's help tweaking a script

Hi everyone!,

I have this script that copies the selected files size to clipboard and I´ts working fine, however i want the script to point to file without me having to select it but I can’t get it to work.

The script looks like this:

on run
tell application “Finder”
set selectedItem to (choose file)
set infoList to {}
copy size of selectedItem as integer to end of infoList
end tell
set {od, AppleScript’s text item delimiters} to {AppleScript’s text item delimiters, return}
set infoAsString to infoList as string
set AppleScript’s text item delimiters to od
set the clipboard to infoAsString
return infoAsString
end run

But i want something like this…

on run
tell application “Finder”
set selectedItem to “Macintosh HD:somefile.wav”
set infoList to {}
copy size of selectedItem as integer to end of infoList
end tell
set {od, AppleScript’s text item delimiters} to {AppleScript’s text item delimiters, return}
set infoAsString to infoList as string
set AppleScript’s text item delimiters to od
set the clipboard to infoAsString
return infoAsString
end run

Best regards Patrik

Is there a particular reason that you wish to use the clipboard?

Hi,

I use the clipboard because it was the only way for me to get the result into my Filemaker database, i use this script to generate the filesize for .wav-files that is stored in the database. The script as it is, is working i have a button inside filemaker that activates the applescript and let’s me select the appropriate file. What i want is to just klick on the button and directly select the file from a stored path in Filemaker. I can make this happen but i can’t get applescript to select the file:

 set selectedItem to (choose file) = makes me select the file in a finder window

but I would like something like

set selectedItem to “Macintosh HD:somefile.wav” = I know how to pass this variable from filemaker to applescript but it just doesn’t work and being a newbie i can’t figure out how to make it work, any help is appreciated

Best

Patrik

I created a very simple FileMaker Database containing two cells: path & size.

I populated the path cell with path such as

HD:Users:username:Desktop:59056-03_A.pdf

and created a button on the layout. The button runs a script which performs a native applescript. The script is as follows:

set theFile to cell "Path" of current record
set theSize to size of (info for file theFile) as integer
set cell "size" of current record to theSize

or the oneliner

set cell "size" of current record to size of (info for file (cell "Path" of current record)) as integer

This works as expected… Granted there is no error checking and you must hit the button manually for each record, but it gives you a place to work from.

Hi,

Thanks!! the above worked perfect, it seems that i hit the jackpot registering to this forum :slight_smile:

again many thanks James!!

Glad to be of service :smiley: