Created
August 18, 2015 21:24
-
-
Save kubido/52211316997d8b8e1f7d to your computer and use it in GitHub Desktop.
rename list youtube downloaded files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
keyword = "(Part" | |
files = Dir.entries('.').select{|x| x.include?(keyword)} | |
files.each do |file| | |
wor = file.match(/( \()(.+)(?=.mp4)/)[0] | |
num = wor.match(/([0-9]+)/)[0] | |
num = (num.to_i < 10)? "#{0}#{num}" : num | |
new_name = "#{num}. #{file.gsub(wor, '')}" | |
File.rename(file, "#{Dir.pwd}/#{new_name}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment