how to copy into multiple line into their orig line
-
I am trying to make a simple move script and it involve hundred of files
how can I copy content into their original line
Example
1.txt
2.txt
3.txt
into this
1.txt 1.txt
2.txt 2.txt
3.txt 3.txt -
Hello, @fujiyamavolcano, and All,
Very easily, indeed ! No need for a script language to achieve that simple task. Just use a regular expression search/replacement.
-
Open the Replace dialog
-
Type in
(?-s)^.+
in the Find what: zone -
Type in
$0\x20$0
in the Replace with: zone -
Select the
wrap around
( or theIn selection
option if you restrict replacement to a previous selection ) -
Click on the Replace All option
That regex replaces any text, of a line, with two copies of that text, separated by a space character, in the same line !
So, from the initial text :
This is a test 12345 1.txt 2.txt 3.txt *--*
You obtain, after replacement,
This is This is a test a test 12345 12345 1.txt 1.txt 2.txt 2.txt 3.txt 3.txt *--* *--*
Notes :
-
The
(?-s)
modifier ensures that the special.
character will match a single standard character, only, and not the End of Line characters -
Then, the part
.+
represents any non-empty range of standard characters , of each line, starting at beginning of line (^
) -
In replacement, we rewrite the overall match (
$0
), followed with a space character (\x20
), and, finally, followed again with the overall match ($0
)
Remarks :
-
In replacement, you may insert a simple space character ( or more, if necessary ) , instead of the
\x20
syntax -
You may, also, write multiple copies, of each initial line, in the same line. For instance, with the initial text, above, the regex S/R :
SEARCH
(?-s)^.+
REPLACE
Line repeated 3 times : | $0 | $0 | $0 |
would product the following test :
Line repeated 3 times : | This is | This is | This is | Line repeated 3 times : | a test | a test | a test | Line repeated 3 times : | 12345 | 12345 | 12345 | Line repeated 3 times : | 1.txt | 1.txt | 1.txt | Line repeated 3 times : | 2.txt | 2.txt | 2.txt | Line repeated 3 times : | 3.txt | 3.txt | 3.txt | Line repeated 3 times : | *--* | *--* | *--* |
Best Regards,
guy038
-
-
@guy038 thanks
you got upvoted