Solved

return files

Posted on 2014-12-19
6
106 Views
Last Modified: 2014-12-23
Hi
I wantt to be able to run a script where the output lists directories and paths to certain file extensions.
For example *.rpt .......
the output might look like ...
c:/reports/a.rpt
c:/reports/b.rpt
c:/reports/test/c.rpt
etc
Regards
0
Comment
Question by:PHIL Sawyer
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:Andrew Doades
ID: 40509528
require 'rubygems'
require 'fileutils'
require 'find'

Dir.chdir("C:\reports")
Dir["*.rpt"].each do |tempfile|
    puts "Found File #{tempfile} in folder #{Dir.pwd}"
end #xml each
0
 
LVL 10

Accepted Solution

by:
Andrew Doades earned 500 total points
ID: 40509533
... OR


Dir.chdir("C:\reports")
  folders = Dir.glob("**/")
  for fldr in folders
    Dir.chdir("#{fldr}") do
      Dir["*.rpt"].each do |tempfile|
      puts "Found File #{tempfile} in folder #{Dir.pwd}"
    end #chdir
  end #xml each
end#folders
0
 

Author Comment

by:PHIL Sawyer
ID: 40514528
Thanks
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:PHIL Sawyer
ID: 40514537
Is there a way I can sort the output alphabetically for the report names
0
 

Author Comment

by:PHIL Sawyer
ID: 40514639
It's ok I've managed to do it.

Regards
0
 

Author Closing Comment

by:PHIL Sawyer
ID: 40514640
Thanks
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now