Created
September 22, 2010 16:25
-
-
Save morganp/592017 to your computer and use it in GitHub Desktop.
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 | |
#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