Skip to content

Instantly share code, notes, and snippets.

@mweppler
Created October 4, 2012 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mweppler/3831623 to your computer and use it in GitHub Desktop.
Save mweppler/3831623 to your computer and use it in GitHub Desktop.
Move files sorted by video/source into same directory
#!/usr/bin/env ruby
require 'fileutils'
Dir.glob('/Volumes/Share/Media/Videos/Software\ Training/video/*').each do |file|
fn = File.basename file, File.extname(file)
sd = File.dirname(file) + '/../' + 'source/'
sf = sd + fn + '.zip'
nd = File.dirname(file) + '/../' + fn
(File.exists? nd) ? next : Dir.mkdir(nd)
FileUtils.mv file, nd
FileUtils.mv sf, nd if File.exists? sf
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment