• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Renaming subtitles.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Renaming subtitles.


  • Subject: Re: Renaming subtitles.
  • From: "koenig.yvan" <email@hidden>
  • Date: Mon, 01 Apr 2013 17:01:39 +0200


Le 01/04/2013 à 16:19, Manuel <email@hidden> a écrit :

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

Why are you using folder actions when you aren't using this_folder or these_items ?
It seems that it would be more logical to use an applet like that (I didn't tested it).

on run
set fileExtensions to {"mkv", "mp4"}
tell application "Finder"
set origen to files of folder "TV SERIES" of disk "WINOSX"
try
repeat with subtitle in origen
if name extension of subtitle is "srt" then exit repeat
end repeat


repeat with episode in origen
if name extension of episode is in fileExtensions then
set episodename to name of episode
set episodenameNoExtension to (text 1 thru -5 in episodename)
if name of subtitle contains (text 1 thru 7 in episodename) then
set the name of subtitle to episodenameNoExtension & ".srt"
end if
end if
end repeat
end try
end tell
end run


Yvan KOENIG (VALLAURIS, France) lundi 1 avril 2013 17:01:22



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Next by Date: Re: Renaming subtitles.
  • Next by thread: Re: Renaming subtitles.
  • Index(es):
    • Date
    • Thread