add new text in multiple files
-
Hello, @rajesh-patil ,
Some precisions :
-
Does the new line
(include "car_crew.inc")need to be inserted once or several times in each file ? -
Is this line be inserted always at the same location ? ( I mean, for instance, always between the present lines
7and8! ) -
Will the lines
(include "/properties/car.ext")and(include "/properties/shadow/tank.inc" scale(1.0))always surround this new line ?
See you later,
Best Regards,
guy038
-
-
•Does the new line (include “car_crew.inc”) need to be inserted once or several times in each file ?
yes
•Is this line be inserted always at the same location ? ( I mean, for instance, always between the present lines 7 and 8 ! )
yes
•Will the lines (include “/properties/car.ext”) and (include “/properties/shadow/tank.inc” scale(1.0)) always surround this new line ?
yesall files are same…just want to insert (include “car_crew.inc”) in every file…there are too many files it will take me forever
-
not exactly same top lines same bottom property are change…………….
I cant edit my post…waiting time 2100…what is this ?
-
Hi, @rajesh-patil,
Regarding the limited time of editing, it’s due to some spam attacks we had in the past, on this site. I agree with you and many others users that this delay should be highly increased for a nicer work. By now, only moderators of this site may re-open and change their own posts, without any limit !
Regarding your problem, I didn’t clearly understand and I’m rather confused ! We must find some parameter(s) which identify, without ambiguity, the location where this line have to be inserted. For example :
-
Is it always after line
7, or any other, of each file ? -
Or, as you said, must this line be inserted between two lines, which are always the same, whatever the file to scan ?
-
Or ?
Cheers,
guy038
-
-
(include “/properties/car.ext”)
(include “/properties/shadow/tank.inc” scale(1.0))
(include “/properties/selection/vehicle.inc” scale(1.1))
{collider “truck”}this top line are same in every file
(include “/properties/car.ext”)
(include “car_crew.inc”) <-----can inserted here
(include “/properties/shadow/tank.inc” scale(1.0))
<------------ or inserted here
(include “/properties/selection/vehicle.inc” scale(1.1))
<------------- or inserted here
{collider “truck”}
<------------- or inserted hereall I want insert this single line (include “car_crew.inc”) in all file at once
-
Hi, @rajesh-patil and All,
Ok ! So, in other words, if you don’t mind about the location, among the four possible ones, that you proposed, we could simply tell that you need to insert the line
(include "car_crew.inc"), after the line(include "/properties/car.ext")which always begins every file, which are to be scanned.If so :
-
First, I strongly advice you to backup your original files, before any operation !
-
Then, open the Find in Files dialog (
Ctrl + Shift + F) -
Type the regex
(?-is)^(\(include "/properties/car.ext"\)\R)(?s)(.+), in the Find what: zone -
Type the regex
\1\(include "car_crew.inc"\)\r\n\2, in the Replace with: zone -
Fill the two other fields Filters and Directory:, as you like
-
Select the
Regular expressionsearch mode -
Click on the
Replace in filesbutton and confirm the changes
Et voilà !
Cheers,
guy038
-
-
[link text]https://www.dropbox.com/s/9nttlapfrk7jrmx/notpad%2B%2B.jpg?dl=0(link url)
0 occurrences where replaced…plz check pic
-
hi,
thanks for helping me…its works…but its works with only with first line…in my case{game_entity
(include “/properties/car.ext”)
(include “/properties/shadow/tank.inc” scale(0.9))
(include “/properties/selection/vehicle.inc” scale(1.1))
{mass 1380}
(?-is)^((include “/properties/car.ext”)\R)(?s)(.+),
\1(include “car_crew.inc”)\r\n\2,not works
(?-is)^({game_entity\R)(?s)(.+)
\1(include “car_crew.inc”)\r\n\2,works
is it possible insert text between any line ?
-
Hi, @rajesh-patil and All,
OK, I understand ! I wrongly supposed that your text began the line, physically. But, of course, most of the time, your text is indented !
In that case change, both, the search
ANDthe replacement part with the regexes below :SEARCH :
(?-is)^((\h+)\(include "/properties/car.ext"\)\R)(?s)(.+)REPLACE :
\1\2\(include "car_crew.inc"\)\r\n\3Everything should be OK :-))
Remark :
IF your text contains several lines
(include "/properties/car.ext"), in files, be aware that the regex S/R, above, adds the line(include "car_crew.inc"), only after the FIRST occurrence of(include "/properties/car.ext")!If all is OK, I could, next time, give you some explanations on these regexes !
To get further information, you should have a look about the FAQ Desk post, below :
https://notepad-plus-plus.org/community/topic/15765/faq-desk-where-to-find-regex-documentation/1
See you later
Best Regards
guy038
-
it works ….thank you so much…
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login