Solved

return files

Posted on 2014-12-19
6
115 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 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
Technology Partners: 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

695 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