Read-only error with AppleScript
I have folder with several video files on my mac. They're videos of players on my baseball team who want to send clips to college coaches. To help, I put the players' names as a "subtitle." I've been manually creating text files, but I want to automate the process bacause there are multiple files each week. I've tried to write an applescript that does three things. First, the script creates text files for each video file with the same basename as each of the video files in the open finder window (the video files are players' names and dates, like "Brian Jones 6June2022.mp4". Second, it adds three lines of text to each text file. The first line of text should be “[1]”, the second line of text should be “00.00.00.000 – 00.00.04.000”, and the third line should be the basename of the video file. Third, it changes the text file's extension to “.srt”. I've tried two versions and get the same error message.
on run {input, parameters}
tell application "Finder"
set video_files to every file of the target of the front Finder window whose name extension is "mp4"
repeat with video_file in video_files
set base_name to name of video_file
set documents_folder to path to documents folder
set text_file to (documents_folder as string) & base_name & ".txt"
do shell script "echo '[1]' > " & text_file
do shell script "echo '00.00.00.000 - 00.00.04.000' >> " & text_file
do shell script "echo " & base_name & " >> " & text_file
do shell script "mv " & text_file & " " & (documents_folder as string) & base_name & ".srt"
end repeat
end tell
return input
end run
I've also tried:
on run {input, parameters}
tell application "Finder"
set video_files to every file of the target of the front Finder window whose name extension is "mp4"
repeat with video_file in video_files
set base_name to name of video_file
set desktop_folder to path to desktop folder
set text_file to (desktop_folder as string) & base_name & ".txt"
do shell script "echo '[1]' > " & text_file
do shell script "echo '00.00.00.000 - 00.00.04.000' >> " & text_file
do shell script "echo " & base_name & " >> " & text_file
do shell script "mv " & text_file & " " & (desktop_folder as string) & base_name & ".srt"
end repeat
end tell
return input
end run
Any suggestions would be greatly appreciated.
MacBook Pro