Hi all - I’m very new to Applescript (so far only needed it for extending Flash projectors to open files).
I’ve decided that I want to make a Filemaker Pro database (something I’m plenty experienced with) to catalog the files (not the folders) located on my CDs & DVDs. I know that disk catalogue apps exist, but none seem very flexible in terms of storing information other than what’s available in the file system.
So I’ll be created some related db’s to store a “CD” record in one DB, which is related to multiple “file” records in another DB. And then, thanks to FMP’s easy customization, I can add other information files about the files themselves (e.g. title, genre, medium, filename, summary, year, etc.). Once that’s in place it’ll be a snap to search for files by various criteria, sort, etc.
Where Actionscript comes in, I want to extend FMP by having an applescript which can recursively parse a disk’s enter automatically a “file” record for the given volume. I found a great head start in terms of a recursive directory crawler that increments a counter for every file it finds.
here’s its code:
property file_count : 0
set the_folder to (choose folder)
set file_count to 0
my count_files(the_folder, true)
return file_count
on count_files(the_folder, with_subs)
set the_folder to the_folder as alias
tell application "Finder"
set the_files to files of the_folder
set file_count to file_count + (count of the_files)
if with_subs = true then
set the_subfolders to folders of the_folder
repeat with this_subfolder in the_subfolders
my count_files(this_subfolder, with_subs)
end repeat
end if
end tell
end count_files
Obviously the counter is incremented in this line
set file_count to file_count + (count of the_files)
however, I am totally not understanding the syntax required to access the filepath and filename and then append one or both to a list (is the & involved?). In theory I wouldn’t even need to do that if I simply swap in an FMP call to dump the filename to the new related record, but I wanted to see stuff in the event log to confirm I hooked in before trying to send data to another app.
If anyone has any tips on how to proceed, let me know! I’m not doing this for profit or anything (just a way to organize my life). I will be sharing it when complete.