473,758 Members | 5,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inserting a line before a certain text in multiple files in a folder

2 New Member
Hi all,

I have a folder named "folder" having multiple files inside different nested folders.
Many files under it have a certain text that i am looking for. Before this line, I have to add a line and save it.

The certain text is something like:
return xyz;
}

If its this I want to add a line just before return xyz;
printf("xyz");

if the certain text (return xyz) is present but no ( } ), then I want to add
{
printf("xyz");
certain text(return xyz;)
}


.... The file in which i find such text, i to add a nth line.

thanks.
Sep 18 '08 #1
1 1383
nithinpes
410 Recognized Expert Contributor
Let us know what you have tried so far.
To parse through hierarchial directory structure (multiple sub-folders), you can make use of File::Find module.
Sep 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1536
by: Jaunty Edward | last post by:
Hi, My problem is a little advance I feel, please check it and guide me if you can. I have a lot of similar format text files, that has name in the first line then age in forth line second and then discription of the person in the 6 line which is a lot of text para and does not have any <br> tag. What I want is to have a script that can read the files in the folder
0
2046
by: GreenFROG Design | last post by:
Data Processing and SQL INSERTING Hello guy's i'm faced with a horrible dilemma i have whole dictionary that i have to enter into a database. I have all the text and i would like to convert it into a sql insert query so i don't have to enter all that data manually. I would like some recommendation on the best way i could get this data into the data. If anyone has any suggestions please help. this is what I'm facing.
5
23058
by: gwarning! | last post by:
Goal: Have multiple text files, each of various lengths, be concatenated together into one final consolidated text file. Problem: Since the names of the files to be concatenated can change from day to day, I need to be able to dynamically generate a batch file to concatenate these files. So far, I have looked at using FileSearch.FindFiles.Count to determine the number of files so that I can loop through the files that exist in a...
6
41965
by: tomtown.net | last post by:
Hello I'm trying to get a single line removed from a text file using a search pattern (pretty simple: if line contains "NODE1") -> remove line). To achieve this I's like to operate with only the original file and no temp file since the file is 1. on a network resource 2. pretty big 3. accessed by plenty of clients. Copying the file or reading everything into an array and then writing it back using the StreamWriter would lock the file...
4
3659
by: Zenon | last post by:
I have been tasked with writing code which overrides the TraceListener class for the purpose of limiting the size of the log file. Basically, when the log file grows to a certain size, I need to begin overwriting it from the beginning. I am using a ReadWrite Stream to do this. My problem is the fact that the lines which are to overwrite the old ones are not necessarily going to be the same size. For instance, if the first line in the...
6
3502
by: Homer J. Simpson | last post by:
Hi all, I have enough experience with HTML/classic ASP to get by, and I'm trying to learn ASP.NET. Traditionally, I've taken the habit of breaking out extra-long CSS files into multiple, smaller ones, and referring to them in my HTML/ASP files on an as-needed basis. Essentially, I've organized things as: /default.asp
10
3689
by: kimiraikkonen | last post by:
Hi, I have an app which has a listbox and when i double click an associated fileS, i want their paths to be added into listbox in my application. This code works good when i try to open a "single" file with my app which works to get commandline arguments to get file paths: Dim cla As String() = Environment.GetCommandLineArgs() If cla.Length 1 Then
15
2452
by: spazzo6281 | last post by:
Hello, is there a way to search a folder for certain files containing a wildcard or certain text entered into a text box. Right now all i can get is the whole list of files from a folder using the following code: lstbox.additems.addrange(IO.directory.getfiles("c:\")) How can i just return only files with matching text as whats in the text Box. Any help will be greatly appreciated. Thanks. Matt
3
1627
by: kanishka1213 | last post by:
html file to be parsed is a simple file i can print the line where age;2 occured but somehow when i extract it, it doesnt go into db as 2 but as "absent". this means the html file entries are not being parsed.or if parsed but not assinged to the hash variable .. there is no problem with first and last element i can get their values correctly in db. but not for age.
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.