Skip to content

Instantly share code, notes, and snippets.

@satococoa
Created January 16, 2009 12:16
Show Gist options
  • Save satococoa/47906 to your computer and use it in GitHub Desktop.
Save satococoa/47906 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# 空のディレクトリの中に空のファイルを作る
# gitなどのお供に
require 'pathname'
if ARGV[0] =~ /-{1,2}h+/
puts 'example) ruby mkblank.rb -v /path/to/dir filename'
exit
end
def mkblank(path, fname)
if path.children.length == 0 && path.directory?
`touch #{(path + fname).to_s}`
puts path + fname
else
path.children.each do |child|
if child.directory?
mkblank child, fname
end
end
end
end
begin
if ARGV[0] == nil
path = Pathname('.')
elsif !(path = Pathname(ARGV[0])).exist?
raise 'invalid path'
end
if ARGV[1] == nil
fname = '.blank'
else
fname = ARGV[1]
end
mkblank path, fname
rescue Exception => e
puts e
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment