Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



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

Posts: 2,138
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
__________________
Made2Own

Please login or register to view this content. Registration is FREE

Last edited by Brian07002; 08-15-2009 at 01:53 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-15-2009, 02:50 AM Re: Script help
Brian07002's Avatar
Defies a Status

Posts: 2,138
Name: ...
Location: ...
Trades: 0
anyone?
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 08-15-2009, 07:19 AM Re: Script help
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,515
Name: Chris Hirst
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
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.14702 seconds with 12 queries