Skip to content

Instantly share code, notes, and snippets.

@RoxasShadow
Created October 21, 2012 19:05
Show Gist options
  • Save RoxasShadow/3928110 to your computer and use it in GitHub Desktop.
Save RoxasShadow/3928110 to your computer and use it in GitHub Desktop.
Windows hard link maker
#--
# urls.txt
# D:\Users\Giovanni\Documents\Ebook
# D:\Users\Giovanni\Documents\4A Games | Metro 2033
#++
(paths = []).tap { |paths|
File.read('urls.txt').each_line { |path|
next if path.gsub(/\s+/, '').empty?
path.gsub!(/\n/, '')
ary = path.split ?|
name = ary.length == 1 ? path.split('\\').last : ary[1]
path = ary.length == 1 ? path : ary[0]
paths << {
:path => path,
:name => name.strip
}
}
}.each { |path|
system "cmd.exe /c mklink /D \"#{path[:name]}\" \"#{path[:path]}\""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment