Last active
February 26, 2023 08:39
-
-
Save krmbzds/791eaaeb154e6116fc6730d30370facc to your computer and use it in GitHub Desktop.
Rename podcast transcriptions transcribed by transcribe_anything
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
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