Skip to content

Instantly share code, notes, and snippets.

@iAladdin
Created August 26, 2014 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iAladdin/f8c56d1fa817c28b6fe6 to your computer and use it in GitHub Desktop.
Save iAladdin/f8c56d1fa817c28b6fe6 to your computer and use it in GitHub Desktop.
rename wwdc-subtitles
movs = Dir['./*']
hash = Hash.new
movs.each do |f|
key = f[2,3]
value = f[2,f.length-6]
hash[key] = value
end
srts = Dir["/Users/Aladdin/Workspace/WWDC_2014_Video_Subtitle/*.srt"]
srts.each do |srt|
arg1 = "#{srt}".shellescape
arg2 = "#{srt[0,50]}#{hash[srt[50,3]]}.srt".shellescape
FileUtils.mv(arg1,arg2)
end
@iAladdin
Copy link
Author

iAladdin commented Oct 8, 2014

it should run in irb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment