Jump to content

Subtitles convert batch script


ciss

Recommended Posts

Hey guys,

 

I'm wondering if you know a way to automate with lets say Task Scheduler a task which would do the following:

- find all .srt files, set character from iso-8859-1 to iso-8859-2 and then convert and save them to UTF-8?

 

I tried and adapted this script by miquelx,

but I get "sh: line 7: inotifywait: command not found"

#!/bin/bash
# Srt Encoder
WATCH_PATH="/volume1/MOVIES/"
FROM="iso-8859-2"
TO="utf-8"
ICONV="iconv -f $FROM -t $TO"

inotifywait -m --format '%w%f' -e create -e moved_to -e modify -r $WATCH_PATH |
	while read file; do
		EXT=${file##*.}
		if [ $EXT = "srt" ]
		then
			IS_TARGET=`file "${file}" | grep -i iso-8859`
			if [ "$IS_TARGET" != "" ]; then
				echo "${file} ---- Will be converted!"
				cp "${file}" "${file}.bak"
				$ICONV < "${file}.bak" > "${file}"
			fi
		fi
	done

Any help?

Edited by ciss
Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...