Created
June 22, 2010 18:19
-
-
Save itspriddle/448848 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Sort messages in this folder | |
# | |
# Example: | |
# Before Sort: msg0002, msg0005, msg0010, msg0020 | |
# After Sort: msg0000, msg0001, msg0002, msg0003 | |
def sort! | |
temp = [] | |
messages.each_with_index do |message, index| | |
# message.files is an array of files [msg0000.{txt,wav}] | |
message.files.each do |file| | |
ext = File.extname(file) | |
filename = "#{@path}/temp_msg%04d#{ext}" % index | |
temp << filename | |
File.rename(file, filename) | |
end | |
end | |
temp.each do |t| | |
filename = t.sub('temp_msg', 'msg') | |
File.rename(t, filename) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment