First time posting on this forum + script noobie,
Need Help.
Purpose of this script is to create Filemaker Pro records (with info fields) for each file selected (from a file server) and then send the files to Toast for BD back up.
Average file count is between 5 and 25, but could be higher.
At the current state the script will grow exponentially with every additional file selected. There must be an easier, more organized way to do this.(is there???)
Any help or suggestion on any part of the script would be amazing
set files_to_add to choose file with multiple selections allowed
set DiskID to "001"
set selCount to count files_to_add
if selCount is 1 then
set fileA to item 1 of files_to_add
end if
if selCount is 2 then
set {fileA, fileB} to {item 1 of files_to_add, item 2 of files_to_add}
end if
if selCount is 3 then
set {fileA, fileB, fileC} to {item 1 of files_to_add, item 2 of files_to_add, item 3 of files_to_add}
end if
--ARE THE FILES TOTAL LARGER THAN 50GB?
tell application "Finder"
(*FILL IN MAXIMUM FILESIZE (in mb) HERE -51200MB = 50GB*)
set maximumfilesize to 51200
get size of (item 1 of files_to_add) (*CAN'T GET THIS TO WORK RIGHT*)
set fileSize to result / 1000000
if fileSize is greater than maximumfilesize then
beep
display dialog "Files are larger than 50 GB, Please select less Files" with icon caution buttons {"Cancel", "OK"} default button 1
end if
--SET INFO FOR FILE -A
tell file fileA
set fileName to name
set creationDate to creation date as text
set modificationDate to modification date as text
set fileType to kind of fileA
set fileSize to size
end tell
end tell
--OPEN FILEMAKER
tell application "FileMaker Pro Advanced"
open "Mac HD:Users:Username:Desktop:ServerBU.fp7" for Accounts "Admin" with passwords ""
--CREATE NEW RECORD FOR FILE -A
set theRecord to create new record at table "Files"
tell theRecord
set cell "File Name" to fileName
set cell "File Type" to fileType
set cell "File Size" to fileSize
set cell "File Path" to POSIX path of fileA
set cell "Disk ID" to DiskID
set cell "Show Name" to ""
set cell "Date Created" to creationDate
set cell "Date Modified" to modificationDate
end tell
end tell
--SET INFO FOR FILE -B
if selCount is 2 then
tell application "Finder"
tell file fileB
set fileName to name
set creationDate to creation date as text
set modificationDate to modification date as text
set fileType to kind of fileB
set fileSize to size
end tell
end tell
--SET NEW RECORD FOR FILE -B
tell application "FileMaker Pro Advanced"
set theRecord to create new record at table "Files"
tell theRecord
set cell "File Name" to fileName
set cell "File Type" to fileType
set cell "File Size" to fileSize
set cell "File Path" to POSIX path of fileB
set cell "Disk ID" to DiskID
set cell "Show Name" to ""
set cell "Date Created" to creationDate
set cell "Date Modified" to modificationDate
end tell
end tell
end if
if selCount is 3 then
--SET INFO FOR FILE -B
tell application "Finder"
tell file fileB
set fileName to name
set creationDate to creation date as text
set modificationDate to modification date as text
set fileType to kind of fileB
set fileSize to size
end tell
end tell
--SET NEW RECORD FOR FILE -B
tell application "FileMaker Pro Advanced"
set theRecord to create new record at table "Files"
tell theRecord
set cell "File Name" to fileName
set cell "File Type" to fileType
set cell "File Size" to fileSize
set cell "File Path" to POSIX path of fileB
set cell "Disk ID" to DiskID
set cell "Show Name" to ""
set cell "Date Created" to creationDate
set cell "Date Modified" to modificationDate
end tell
end tell
tell application "Finder"
--SET INFO FOR FILE -C
tell file fileC
set fileName to name
set creationDate to creation date as text
set modificationDate to modification date as text
set fileType to kind of fileC
set fileSize to size
end tell
end tell
--SET NEW RECORD FOR FILE -C
tell application "FileMaker Pro Advanced"
set theRecord to create new record at table "Files"
tell theRecord
set cell "File Name" to fileName
set cell "File Type" to fileType
set cell "File Size" to fileSize
set cell "File Path" to POSIX path of fileC
set cell "Disk ID" to DiskID
set cell "Show Name" to ""
set cell "Date Created" to creationDate
set cell "Date Modified" to modificationDate
end tell
end tell
end if
-- MAKE TOAST BD DL (BLU-RAY)
tell application "Toast Titanium"
activate
set myDisc to make Data disc
set name of myDisc to "Disk " & DiskID
set toast_project to current disc
set file system type of myDisc to Mac OS Standard Hybrid
add to toast_project items files_to_add
set Asking to no
--write myDisc
end tell