Hello, scripters.
I´m trying a folder action to rename the subtitles of some tv shows, but I can´t get it work. This is my script.
My idea is get the 7 first characters of the video file and if the subtitle file matches it, then rename it to the video file name and add the ".srt" extension.
Once this is done I would like to move the TV Show and its subtitle to a folder called "Series Subtituladas" but I haven´t been able to figure it out.
When I run it, I get an Error Number -1728. What am I doing wrong ?
In the picture below I show some files in the folder.
Thank you very much in advance for your time.
on adding folder items to this_folder after receiving these_items
tell application "Finder"
delay 1
set origen to folder "TV SERIES" of disk "WINOSX"
set fileExtensions to {"mkv", "mp4"}
try
repeat with i from 1 to the count of origen
set subtitle to (item i of origen whose name extension is "srt")
set episode to (item i of origen whose name extension is in fileExtensions)
set episodename to name of episode
set episodenameNoExtension to (characters 1 thru -5 in episodename as string)
if name of subtitle contains (characters 1 thru 7) in episodename then
set the name of subtitle to episodenameNoExtension & ".srt"
end if
end repeat
end try
end tell
end adding folder items to