?
Solved

return files

Posted on 2014-12-19
6
Medium Priority
?
116 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

800 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