Skip to content

Instantly share code, notes, and snippets.

@krmbzds
Last active February 26, 2023 08:39
Show Gist options
  • Save krmbzds/791eaaeb154e6116fc6730d30370facc to your computer and use it in GitHub Desktop.
Save krmbzds/791eaaeb154e6116fc6730d30370facc to your computer and use it in GitHub Desktop.
Rename podcast transcriptions transcribed by transcribe_anything
Dir.each_child(".").each do |folder|
Dir.each_child(folder).each do |file|
full_path = File.expand_path(file, folder)
extension = File.extname(full_path)
case extension
when ".txt", ".srt", ".vtt"
new_path = File.join(File.expand_path("..", folder), folder + extension)
File.rename(full_path, new_path)
end
end
rescue
puts "Problem with folder"
puts folder
end
# Remove empty dirs
Dir["**/"].reverse_each { |d| Dir.rmdir(d) if Dir.empty?(d) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment