2 # Make almost all filelist in my computer
5 # * Exclude unused files
6 # * List directory first
9 # * Print all files in computer
10 # ruby make-filelist.rb > all.filelist
11 # * Print specified directories
12 # ruby make-filelist.rb dir1 dir2 ... > partial.filelist
13 # * Use with cron: add this entry to crontab to make filelist at 1:00 AM.
14 # 0 1 * * * ruby /path/to/make-filelist.rb > /tmp/all.filelist
17 # You can override customize variables by creating ~/.make-filelist.rb
20 # ==== Customize Variables ====
21 # Exclude pathnames (version control system directories and so on)
23 . .. lost+found tmp temp
24 autom4te.cache blib _build .bzr .cdv cover_db CVS _darcs ~.dep ~.dot .git .hg ~.nib .pc ~.plst RCS SCCS _sgbak .svn
27 # Exclude regexps (backup files, core files, and so on)
28 $EXCLUDE_REGEXP = Regexp.union(/~$/, /\#.+\#$/, /[._].*\.swp$/, /core\.\d+$/)
30 # Set default directories to collect
32 # ==== End of Customize Variables =====
34 begin load "~/.make-filelist.rb"; rescue LoadError; end # Load configuration file
35 $done = [] # Already collected directory
37 if $done.include? dir or not File.readable? dir
38 $stderr.puts "skipped #{dir}" if $VERBOSE
42 home_re = /^#{Regexp.quote(ENV['HOME'])}/ if ENV['HOME']
43 Dir.foreach(dir) do |f|
45 next if $EXCLUDE_PATH.include? f
46 next if $EXCLUDE_REGEXP.match f
49 abbrev = f.sub(home_re, '~') if ENV['HOME']
50 if stat.directory? and not stat.symlink?
57 $stderr.puts "#{dir}/#{f}: #$!"
66 edir = File.expand_path dir
67 $stderr.puts "ls_first #{edir}" if $VERBOSE
72 (ARGV.empty? ? $LS_DIRS : ARGV).each {|d| ls_first d }