Thanks Vassilis. I’d prefer to not install anything to accomplish
this. Also, I’d like to slightly to rephrase my aim:
Start off in ‘Movies’ directory.
Go into each subdir and get list of movies for that subdir. I’ve
found how to just get the filename instead of full path: Dir[’**/
*.avi’].collect { |vid| File.basename(vid) }
Thanks Vassilis. I’d prefer to not install anything to accomplish
this. Also, I’d like to slightly to rephrase my aim:
Start off in ‘Movies’ directory.
Go into each subdir and get list of movies for that subdir. I’ve
found how to just get the filename instead of full path: Dir[‘**/
*.avi’].collect { |vid| File.basename(vid) }
Thanks Vassilis. I’d prefer to not install anything to accomplish
this. Also, I’d like to slightly to rephrase my aim:
Start off in ‘Movies’ directory.
Go into each subdir and get list of movies for that subdir. I’ve
found how to just get the filename instead of full path: Dir[’**/
*.avi’].collect { |vid| File.basename(vid) }
Store which movies are in each subdir.
Output the result.
Try this:
files = Hash.new { |hash, key| hash[key] = [] }
Dir[’**/*.avi’].each do |file|
files[File.dirname(file)] << File.basename(file)
end
Not sure how you want the output formatted, but I believe that creates
the data structure you’re looking for: