The following applescript is no longer working since I upgraded to Monterey. Can someone please take a look and let me know how to fix this? I would SO appreciate it.
tell application "Finder"
set the_folder to choose folder
set the_folder_name to name of the_folder
set the_subfolders to every folder in the_folder
repeat with I from 1 to count of the_subfolders
set file_name to name of every file of item I of the_subfolders
set name of every file of item I of the_subfolders to the_folder_name & "-" & name of item I of the_subfolders & "-" & file_name
move every file of item I of the_subfolders to the_folder
end repeat
--
-- optionally delete the subfolders
-- delete every folder in the_folder -- put two dashes in front of this line to comment it out
end tell