Skip to content

Instantly share code, notes, and snippets.

@morganp
Created September 22, 2010 16:25
Show Gist options
  • Save morganp/592017 to your computer and use it in GitHub Desktop.
Save morganp/592017 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#List all file below this location
path = File.expand_path( $0 )
puts path
def list_files( files, spacer='', path='.')
path = File.expand_path( path )
files.each do |f|
if File.directory?( f )
puts spacer + f + '/'
recursive_path=File.expand_path( f )
Dir.chdir( recursive_path )
recursive_files = Dir.glob('*')
recursive_spacer = spacer + ' '
list_files(recursive_files, recursive_spacer, recursive_path)
else
puts spacer + f
end
Dir.chdir( path )
end
end
#Dir.chdir( path )
files = Dir.glob('*')
list_files( files )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment