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

Posted on Dec 19, 2022 8:02 AM

Reply

Similar questions

10 replies

Dec 19, 2022 8:43 AM in response to Luis Sequeira1

I'm running these two scripts as an automator workflow. The one that references shell scripts gets: Finder got an error: sh: Macintosh: Read-only file system sh: Macintosh: Read-only file system. The one that is all applescript gets: Finder got an error: Can't make document file "brian jones.mp4.txt" of folder "vids" of folder "Desktop" of folder "turner" of folder "Users" of startup disk into type «class fsrf».

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Read-only error with AppleScript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.