Reply
Old 08-15-2009, 01:28 AM Script help
Brian07002's Avatar
Defies a Status

Posts: 1,589
Name: ...
Location: ...
Trades: 0
Does anyone know where I can download a tool that will allow me to search a folder of 'text files' of any extension (could be .txt or any other name but they contain text) and display result of the number of rows in the text file that i choose?

Example file.info

Hello my name is Brian
This is a 'text' file
Can you print me
Thanks for reading

the tool will allow me to search by the number of rows i choose. if i chose 4 then file.info would be displayed because it has 4 rows.

Figured i'd do in shell, but i still have one more problem. doing in shell leads me to this:

Code:
Wc "/directory*.*"
which does the job, but how could i move those files whose # of rows = # (# is the number of rows in the file) into another directory?

that's what i am looking for.
thanks
__________________
Sig Less - Have some site you want me to put here? Will put here for a couple of paypal bucks.

Last edited by Brian07002; 08-15-2009 at 01:53 AM..
Brian07002 is online now
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 08-15-2009, 02:50 AM Re: Script help
Brian07002's Avatar
Defies a Status

Posts: 1,589
Name: ...
Location: ...
Trades: 0
anyone?
__________________
Sig Less - Have some site you want me to put here? Will put here for a couple of paypal bucks.
Brian07002 is online now
Reply With Quote
View Public Profile
 
Old 08-15-2009, 07:19 AM Re: Script help
chrishirst's Avatar
Super Moderator

Posts: 22,225
Location: Blackpool. UK
Trades: 0
it's simple enough to do in Vb, VbScript or as a .net app.

Is it to run on a webserver (web programming being the primary focus of this forum), or a desktop?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-01-2009, 12:29 PM Re: Script help
Junior Talker

Posts: 1
Trades: 0
So, let me understand.

You want to go to a folder, and display the names of files in that folder that contain the specified number of rows (lines).

Here is a script.

Code:
 
# Script rows.txt
# Input arguments
# folder - the full path of the folder.
# rows - the number of lines to match
 
var str folder ; var int rows
 
# Get a list of files in that folder.
var str list ; lf -n "*" $folder > $list
 
# Go thru the list of files.
while ($list <> "")
do
 
    # Get the next file.
    var str file ; lex "1" $list > $file
 
    # Read the file contents into a string varaible.
    var string content ; cat $file > $content
 
    # Count the number of lines in $content
    var int count ; set $count = { sen $count }
 
    # If the count is same as our input argument rows, echo the file name.
    if ($count == $rows)
        echo $file
    endif
 
done


Script is in biterscripting ( http://www.biterscripting.com ). To try, save the script as C:\Scripts\rows.txt, start biterscripting, enter the following command.

script "C:\Scripts\rows.txt" folder("C:\somefolder") rows(4)

Above command will display all file names that contain 4 rows/lines in folder C:\somefolder.

Jenni
JenniC is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Script help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11898 seconds with 13 queries