Thread: Mass find & replace

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    2

    Mass find & replace

    Hi. I'm just starting with C, I've done quite a bit of programming in some other languages. I find it easy for myself to learn by example, and what better example than a utility I need?

    Basically, I have thousands of files inside hundreds of folders. I want a program to go through those files, and inside each, there may be multiple instances of things like:

    Code:
    example asdf
    attribute1 sdff
    attribute2 12
    attribute3 test
    end
    I need it to search through each of those instances, and find a specified attribute, and change the value. However, there are also rules for other attributes. Example:

    Whenever attribute 2 is equal to 12, make attribute 3 equal "test2".

    Thanks.

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    So what do you want an example of string searching or directory searching? Also what have you attempted thus far?
    Woop?

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Sounds like a job for Perl

    Otherwise, not too hard in C but a bit cumbersome. I would suggest getting the parsing of the files down pat (i.e. for one file at a time), then look at the FAQ which gives examples of a "directory walker".

  4. #4
    Registered User
    Join Date
    Aug 2010
    Posts
    2
    Thanks, but I've just realized that, since I'm a bit low on time, I should probably just stick with a language I'm familiar with. Perhaps I'll try C (and perl) some other time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. HOW TO Find right names for GetProcAddress
    By albert3721 in forum Windows Programming
    Replies: 15
    Last Post: 03-16-2010, 07:55 AM
  3. replace single character with matrix of char
    By rob90 in forum C Programming
    Replies: 7
    Last Post: 12-28-2009, 03:19 PM
  4. How to find the last value in an array
    By mkanimozhi in forum C Programming
    Replies: 2
    Last Post: 12-05-2009, 10:06 PM
  5. How to replace strings in a file?
    By Doh in forum C Programming
    Replies: 6
    Last Post: 11-26-2002, 12:16 PM