Last active
December 16, 2015 05:38
-
-
Save landaire/5385478 to your computer and use it in GitHub Desktop.
Monitors a directory for new MP3 files and moves them to a different directory
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
require 'fileutils' | |
DOWNLOADS_PATH = '/Users/lander/Downloads' | |
while true | |
Dir.foreach(DOWNLOADS_PATH) do |entry| | |
next if !(entry =~ /.mp3$/i) | |
begin | |
FileUtils.mv(File.join(DOWNLOADS_PATH, entry), '/Users/lander/ext_music') | |
puts "Moved: #{File.join(DOWNLOADS_PATH, entry)}}" | |
rescue | |
puts "Couldn't move: #{File.join(DOWNLOADS_PATH, entry)}" | |
end | |
# Wait 30 seconds before the next iteration | |
sleep(30) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment