Solved

return files

Posted on 2014-12-19
6
96 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

19 Experts available now in Live!

Get 1:1 Help Now