I had this script working earlier but I did something to it and can’t figure out my issue.
I want to use this script to append data to the existing file. I keep getting this error… Where did I go wrong ?
Also, can this be improved to only get the folders info and not the folder contents? This is a special use for one folder.
I ripped all my CD’s to FLAC files. I dump the contents of this music folder to iCloud so when I’m hunting new CD’s to rip I have a list of title’s I already have I avoid buying duplicates. Currently this lists the contents or songs of each folder. Thanks
Error message…
File file Macintosh HD:Users:MG:Desktop:abcd.txt is already open." number -49 from file “Macintosh HD:Users:MG:Desktop:abcd.txt” to «class fsrf»
try
close file "abcd.txt"
end try
--Last run date is 02/20/19, modified on 2/20/19 to append data to file via the close file section
property file_id : null
set this_folder to choose folder with prompt "Choose the root folder"
set log_file_path to (path to desktop as string) & "abcd.txt"
set file_id to open for access file log_file_path with write permission
return
write ("Run Date is " & (current date) & return) to file_id starting at eof
my do_subfolders(this_folder, "")
write (return & return) to file_id starting at eof
close access file_id
on do_subfolders(this_folder, name_prefix)
tell application "Finder"
log name_prefix & (name of this_folder) as string
write (return & name_prefix & (name of this_folder) as string) to file_id starting at eof
set file_list to every file in this_folder
repeat with this_file in file_list
log name_prefix & " " & (name of this_file) as string
write (return & name_prefix & " " & (name of this_file) as string) to file_id starting at eof
end repeat
set folder_list to every folder in this_folder
repeat with this_subfolder in folder_list
my do_subfolders(this_subfolder, " " & name_prefix)
end repeat
end tell
end do_subfolders