Created
April 8, 2013 13:54
-
-
Save timoschilling/5336930 to your computer and use it in GitHub Desktop.
ruby script to create recrosive hardlinks of files with directory 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
| #!/bin/ruby | |
| require "fileutils" | |
| src = ARGV.first | |
| dest = ARGV.last | |
| Dir.chdir(src) do | |
| src_dirs = Dir["**/*/"].select{|node| !File.file? node } | |
| src_files = Dir["**/*"].select{|node| File.file? node } | |
| src_dirs.each do |dir| | |
| FileUtils.mkdir_p File.join(dest, dir) | |
| end | |
| src_files.each do |file| | |
| File.link file, File.join(dest, file) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment