1.

Solve : need Batch - read all files and run only scripts when file comment = 'mycomment'?

Answer»

Hello. I am new to creating batch files.

I have a huge folder of ruby scripts that I want to run based on the what is in the file comments. For INSTANCE, in script1.rb comment 'Critical1', script2.rb comment 'Critical2'. All files are categorized like this. Is there a way to run all files that have specific comments? Thanks MC

pseudo snippet:

open folder
read each file
if file comments = 'Critical1'
run all scripts
end
end
endWhat is the comment character in Ruby script?

FBQuote from: fireballs on January 09, 2009, 11:23:00 AM

What is the comment character in Ruby script?

FB

A hash for single line comments

Code: [Select]# This is a comment
Code: [Select]# The famous Hello World
# PROGRAM is trivial in
# Ruby. You don't need:
#
# * a "main" method
# * newline escapes
# * semicolons
#
# Here's the code:

puts "Hello World!"

or alternatively

==begin and ==end for comment blocks

Code: [Select]==begin
This is a comment line
it explains that the next line of code displays
a welcome message
==end
I am seriously wondering about somebody who says "I have a folder of Ruby scripts and I need a batch script to do something with them". Why not write yourself a Ruby script? If your Ruby scripts are crucial for your mission, then you need a competent Ruby programmer on the team.

Please specify how the Ruby scripts are commented.

What do you mean by this?

Quote
run all scripts

Run all of which scripts? Where?

Do you mean, you want to examine (for EXAMPLE) all of the Ruby scripts in a folder, and if a certain script contains a line like this...

Code: [Select]# Critical1
... then run that particular script? Then proceed to the next Ruby script? Until there are no more? Do them in what order?







In a folder directory, there are files, each file has attributes such as...Name, SIZE, Type, Date Modified and Comments.

I wanted to see if it is possible to create a batch to run only scripts that have a specific comment. Yes, I am working on a ruby script to do this..just wanted to see if a batch could do this - that's all. I am guessing maybe not after reading your words.

Thanks for the comments. MCQuote from: mcolli00 on January 09, 2009, 01:14:40 PM
I am guessing maybe not after reading your words.

I misunderstood what you meant by "comment"...

Quote
In a folder directory, there are files, each file has attributes such as...Name, Size, Type, Date Modified and Comments.

OK I'm with you... NTFS Alternate Data Streams. Not easily accessible using batch, but watch this space!

AS far as I know, there is no built-in commandline access to ADS information, but there are 3rd party utilities. Are you permitted to install and use such things?




No I can't user 3rd party softwares. I just wanted to see if I could use a batch program since it seems shorter. I am in the process of creating a script to use some gems in Ruby to get file attributes and create a driver file. I was just hoping for a quicker fix. Thanks MCThose file comments you can see in Windows Explorer are a feature of NTFS Alternate Data Streams and are chiefly used within Windows GUI applications & Windows Explorer. If I wanted to deal with all of the files within a folder that had a particular comment, en masse, I would probably set Explorer to details view, then click on the Comments column heading (in order to group like comments together) then highlight all the ones I wanted, then either cut & paste to another folder, and then process them, or use Send To to send all the filenames to a shortcut in my Send To folder, said shortcut POINTING to a batch file I might write. But I think it would be hard to do it all in a batch. Powerscript maybe...
couldn't one access the "♣SummaryInformation" stream via simple type command and parse it as appropriate?

the special symbol kind of confuses things, though.the "♣" is ^F i.e. ctrl+F in DOS.

FB


Discussion

No Comment Found