Created
August 31, 2013 03:43
-
-
Save bhollis/6396105 to your computer and use it in GitHub Desktop.
Simple script for moving files to another directory while preserving their folder structure.
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
#!/usr/bin/env ruby | |
# Usage: deepmv '**/*.rb' ../other | |
# | |
# Moves files under the current directory matching a glob | |
# to another directory, preserving directory structure. | |
require 'fileutils' | |
glob = ARGV.shift | |
dest = ARGV.shift | |
Dir.glob(glob) do |f| | |
destfile = File.join(dest, f) | |
FileUtils.mkdir_p File.dirname(destfile) | |
FileUtils.mv f, destfile | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment