Skip to content

Instantly share code, notes, and snippets.

@franciscomxs
Last active September 13, 2015 04:42
Show Gist options
  • Save franciscomxs/8df6543136cd7cb6810b to your computer and use it in GitHub Desktop.
Save franciscomxs/8df6543136cd7cb6810b to your computer and use it in GitHub Desktop.
Rename my animes and series to use Episode.Extension format
REGEX = /([0-9]{2,3}).*([\.mp4|\.mkv|.rmvb|.avi]{4,5})/
Dir['*'].each do |file_name|
if (match = REGEX.match(file_name)) && File.exist?(file_name)
new_name = "#{match[1]}#{match[2]}"
File.rename(file_name, new_name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment