Automate copying part of a text and paste it somewhere else on the same line for multiple lines
I have text files with some information I want to copy from one place and paste somewhere else on the same line. For instance, I have something like:
Random text here { Name = "Tropical Smoothie", UniqueId = "1110100", More random text};
Random text here { Name = "Tropical Smoothie", UniqueId = "1110110", More random text};
Random text here { Name = "Tropical Mango Smoothie", UniqueId = "1110120", More random text};
.
.
.
Random text here { Name = "Tropical Smoothie", UniqueId = "2000110", More random text};
and I want the numbers after UniqueId to be copied and placed at the end of Smoothie on the same line like so
Random text here { Name = "Tropical Smoothie 1110100", UniqueId = "1110100", More random text};
Random text here { Name = "Tropical Smoothie 1110110", UniqueId = "1110110", More random text};
Random text here { Name = "Tropical Mango Smoothie 1110120", UniqueId = "1110120", More random text};
.
.
.
Random text here { Name = "Tropical Smoothie 2000110", UniqueId = "2000110", More random text};
As long as there is a space after the words that are in quotes after Name and then the UniqueId numbers. The name can be anything, the UniqueId is unique for each line.
So using the first line as example, in a text editor I would highlight 1110100 and copy it and put a space after Smoothie then paste. Then I would do the same thing for the next line and so on.
Can this task be automated somehow for each line? I'll try any script or Windows program.
Even something that does "for each line copy 7 digits after 3rd double-quotes and paste before 2nd double-quotes" or some such would work.
windows-10 textfiles
|
show 7 more comments
I have text files with some information I want to copy from one place and paste somewhere else on the same line. For instance, I have something like:
Random text here { Name = "Tropical Smoothie", UniqueId = "1110100", More random text};
Random text here { Name = "Tropical Smoothie", UniqueId = "1110110", More random text};
Random text here { Name = "Tropical Mango Smoothie", UniqueId = "1110120", More random text};
.
.
.
Random text here { Name = "Tropical Smoothie", UniqueId = "2000110", More random text};
and I want the numbers after UniqueId to be copied and placed at the end of Smoothie on the same line like so
Random text here { Name = "Tropical Smoothie 1110100", UniqueId = "1110100", More random text};
Random text here { Name = "Tropical Smoothie 1110110", UniqueId = "1110110", More random text};
Random text here { Name = "Tropical Mango Smoothie 1110120", UniqueId = "1110120", More random text};
.
.
.
Random text here { Name = "Tropical Smoothie 2000110", UniqueId = "2000110", More random text};
As long as there is a space after the words that are in quotes after Name and then the UniqueId numbers. The name can be anything, the UniqueId is unique for each line.
So using the first line as example, in a text editor I would highlight 1110100 and copy it and put a space after Smoothie then paste. Then I would do the same thing for the next line and so on.
Can this task be automated somehow for each line? I'll try any script or Windows program.
Even something that does "for each line copy 7 digits after 3rd double-quotes and paste before 2nd double-quotes" or some such would work.
windows-10 textfiles
that text looks suspiciouly... how to say it... a programmer kinda thing. Doesfgets()
sound familiar to you?, if not, well, I'm sorry, I don't know any Windows program that solves this specific problem. Can you compile code by any chance?
– Jenny T-Type
Dec 18 '18 at 5:13
No I can't compile. This example is text from a .cs file but I'm not looking for a programming solution as I have other text files that I want to be able to do the same thing with.
– joetex72
Dec 18 '18 at 6:00
What tools do you have avaliable? cmd, python, bash?
– dmb
Dec 18 '18 at 11:23
Yes I'll try any Windows program, script or app like cmd, Powershell, VBS or download any tool. Not familiar with fgets @JennyT-Type.
– joetex72
Dec 18 '18 at 12:04
fgets()
is a C function that reads a line from a file in put it in a string, I only mention it cause I thought that you might know a little bit of programming, (C is a programming language). I asked you if you can compile cause I was willing to write a program for you to compile in your machine, but setting a cross-compiler just for you, well, not so much. though I'm giving it a though.
– Jenny T-Type
Dec 18 '18 at 20:13
|
show 7 more comments
I have text files with some information I want to copy from one place and paste somewhere else on the same line. For instance, I have something like:
Random text here { Name = "Tropical Smoothie", UniqueId = "1110100", More random text};
Random text here { Name = "Tropical Smoothie", UniqueId = "1110110", More random text};
Random text here { Name = "Tropical Mango Smoothie", UniqueId = "1110120", More random text};
.
.
.
Random text here { Name = "Tropical Smoothie", UniqueId = "2000110", More random text};
and I want the numbers after UniqueId to be copied and placed at the end of Smoothie on the same line like so
Random text here { Name = "Tropical Smoothie 1110100", UniqueId = "1110100", More random text};
Random text here { Name = "Tropical Smoothie 1110110", UniqueId = "1110110", More random text};
Random text here { Name = "Tropical Mango Smoothie 1110120", UniqueId = "1110120", More random text};
.
.
.
Random text here { Name = "Tropical Smoothie 2000110", UniqueId = "2000110", More random text};
As long as there is a space after the words that are in quotes after Name and then the UniqueId numbers. The name can be anything, the UniqueId is unique for each line.
So using the first line as example, in a text editor I would highlight 1110100 and copy it and put a space after Smoothie then paste. Then I would do the same thing for the next line and so on.
Can this task be automated somehow for each line? I'll try any script or Windows program.
Even something that does "for each line copy 7 digits after 3rd double-quotes and paste before 2nd double-quotes" or some such would work.
windows-10 textfiles
I have text files with some information I want to copy from one place and paste somewhere else on the same line. For instance, I have something like:
Random text here { Name = "Tropical Smoothie", UniqueId = "1110100", More random text};
Random text here { Name = "Tropical Smoothie", UniqueId = "1110110", More random text};
Random text here { Name = "Tropical Mango Smoothie", UniqueId = "1110120", More random text};
.
.
.
Random text here { Name = "Tropical Smoothie", UniqueId = "2000110", More random text};
and I want the numbers after UniqueId to be copied and placed at the end of Smoothie on the same line like so
Random text here { Name = "Tropical Smoothie 1110100", UniqueId = "1110100", More random text};
Random text here { Name = "Tropical Smoothie 1110110", UniqueId = "1110110", More random text};
Random text here { Name = "Tropical Mango Smoothie 1110120", UniqueId = "1110120", More random text};
.
.
.
Random text here { Name = "Tropical Smoothie 2000110", UniqueId = "2000110", More random text};
As long as there is a space after the words that are in quotes after Name and then the UniqueId numbers. The name can be anything, the UniqueId is unique for each line.
So using the first line as example, in a text editor I would highlight 1110100 and copy it and put a space after Smoothie then paste. Then I would do the same thing for the next line and so on.
Can this task be automated somehow for each line? I'll try any script or Windows program.
Even something that does "for each line copy 7 digits after 3rd double-quotes and paste before 2nd double-quotes" or some such would work.
windows-10 textfiles
windows-10 textfiles
edited Dec 18 '18 at 10:48
joetex72
asked Dec 18 '18 at 3:10
joetex72joetex72
104
104
that text looks suspiciouly... how to say it... a programmer kinda thing. Doesfgets()
sound familiar to you?, if not, well, I'm sorry, I don't know any Windows program that solves this specific problem. Can you compile code by any chance?
– Jenny T-Type
Dec 18 '18 at 5:13
No I can't compile. This example is text from a .cs file but I'm not looking for a programming solution as I have other text files that I want to be able to do the same thing with.
– joetex72
Dec 18 '18 at 6:00
What tools do you have avaliable? cmd, python, bash?
– dmb
Dec 18 '18 at 11:23
Yes I'll try any Windows program, script or app like cmd, Powershell, VBS or download any tool. Not familiar with fgets @JennyT-Type.
– joetex72
Dec 18 '18 at 12:04
fgets()
is a C function that reads a line from a file in put it in a string, I only mention it cause I thought that you might know a little bit of programming, (C is a programming language). I asked you if you can compile cause I was willing to write a program for you to compile in your machine, but setting a cross-compiler just for you, well, not so much. though I'm giving it a though.
– Jenny T-Type
Dec 18 '18 at 20:13
|
show 7 more comments
that text looks suspiciouly... how to say it... a programmer kinda thing. Doesfgets()
sound familiar to you?, if not, well, I'm sorry, I don't know any Windows program that solves this specific problem. Can you compile code by any chance?
– Jenny T-Type
Dec 18 '18 at 5:13
No I can't compile. This example is text from a .cs file but I'm not looking for a programming solution as I have other text files that I want to be able to do the same thing with.
– joetex72
Dec 18 '18 at 6:00
What tools do you have avaliable? cmd, python, bash?
– dmb
Dec 18 '18 at 11:23
Yes I'll try any Windows program, script or app like cmd, Powershell, VBS or download any tool. Not familiar with fgets @JennyT-Type.
– joetex72
Dec 18 '18 at 12:04
fgets()
is a C function that reads a line from a file in put it in a string, I only mention it cause I thought that you might know a little bit of programming, (C is a programming language). I asked you if you can compile cause I was willing to write a program for you to compile in your machine, but setting a cross-compiler just for you, well, not so much. though I'm giving it a though.
– Jenny T-Type
Dec 18 '18 at 20:13
that text looks suspiciouly... how to say it... a programmer kinda thing. Does
fgets()
sound familiar to you?, if not, well, I'm sorry, I don't know any Windows program that solves this specific problem. Can you compile code by any chance?– Jenny T-Type
Dec 18 '18 at 5:13
that text looks suspiciouly... how to say it... a programmer kinda thing. Does
fgets()
sound familiar to you?, if not, well, I'm sorry, I don't know any Windows program that solves this specific problem. Can you compile code by any chance?– Jenny T-Type
Dec 18 '18 at 5:13
No I can't compile. This example is text from a .cs file but I'm not looking for a programming solution as I have other text files that I want to be able to do the same thing with.
– joetex72
Dec 18 '18 at 6:00
No I can't compile. This example is text from a .cs file but I'm not looking for a programming solution as I have other text files that I want to be able to do the same thing with.
– joetex72
Dec 18 '18 at 6:00
What tools do you have avaliable? cmd, python, bash?
– dmb
Dec 18 '18 at 11:23
What tools do you have avaliable? cmd, python, bash?
– dmb
Dec 18 '18 at 11:23
Yes I'll try any Windows program, script or app like cmd, Powershell, VBS or download any tool. Not familiar with fgets @JennyT-Type.
– joetex72
Dec 18 '18 at 12:04
Yes I'll try any Windows program, script or app like cmd, Powershell, VBS or download any tool. Not familiar with fgets @JennyT-Type.
– joetex72
Dec 18 '18 at 12:04
fgets()
is a C function that reads a line from a file in put it in a string, I only mention it cause I thought that you might know a little bit of programming, (C is a programming language). I asked you if you can compile cause I was willing to write a program for you to compile in your machine, but setting a cross-compiler just for you, well, not so much. though I'm giving it a though.– Jenny T-Type
Dec 18 '18 at 20:13
fgets()
is a C function that reads a line from a file in put it in a string, I only mention it cause I thought that you might know a little bit of programming, (C is a programming language). I asked you if you can compile cause I was willing to write a program for you to compile in your machine, but setting a cross-compiler just for you, well, not so much. though I'm giving it a though.– Jenny T-Type
Dec 18 '18 at 20:13
|
show 7 more comments
1 Answer
1
active
oldest
votes
You asked the same question on StackOverflow where I just wrote you an answer. I am supplying the same answer here as well.
You can accomplish what you are asking by using any text editor that supports Regex. In this example, I will be using Notepad++. First I will describe what to do, then after I will explain what the Regex does.
Example
- Open the file with
Notepad++
. - Press
Ctrl+F
to bring up theSearch and Replace
window. - Make sure to check the box named
Wrap around
- Select
Regular expression
underSearch Mode
- Under
Find What:
insertName = "(.*)", UniqueId = "(d+)"
- Under
Replace with:
insertName = "$1 $2", UniqueId = "$2"
- Press
Replace all
once.
Understanding the regex
()
these characters represent a group that you want to capture.
$1
represent the first group that you marked with()
$2
same thing but it takes the second group.
d
matchesany digit
.+
after a digit means, match one or more digits.
.
matchesany character
.*
after the dot means match zero or more characters.
In the search example Name = "(.*)", UniqueId = "(d+)"
we have two groups. Matching the content in between the quotes of Name and UniqueId.
In the replace example Name = "$1 $2", UniqueId = "$2"
, we are using these groups to replace what we match with something new. The new is, in this case, the contents of group $1
and group $2
.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385414%2fautomate-copying-part-of-a-text-and-paste-it-somewhere-else-on-the-same-line-for%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You asked the same question on StackOverflow where I just wrote you an answer. I am supplying the same answer here as well.
You can accomplish what you are asking by using any text editor that supports Regex. In this example, I will be using Notepad++. First I will describe what to do, then after I will explain what the Regex does.
Example
- Open the file with
Notepad++
. - Press
Ctrl+F
to bring up theSearch and Replace
window. - Make sure to check the box named
Wrap around
- Select
Regular expression
underSearch Mode
- Under
Find What:
insertName = "(.*)", UniqueId = "(d+)"
- Under
Replace with:
insertName = "$1 $2", UniqueId = "$2"
- Press
Replace all
once.
Understanding the regex
()
these characters represent a group that you want to capture.
$1
represent the first group that you marked with()
$2
same thing but it takes the second group.
d
matchesany digit
.+
after a digit means, match one or more digits.
.
matchesany character
.*
after the dot means match zero or more characters.
In the search example Name = "(.*)", UniqueId = "(d+)"
we have two groups. Matching the content in between the quotes of Name and UniqueId.
In the replace example Name = "$1 $2", UniqueId = "$2"
, we are using these groups to replace what we match with something new. The new is, in this case, the contents of group $1
and group $2
.
add a comment |
You asked the same question on StackOverflow where I just wrote you an answer. I am supplying the same answer here as well.
You can accomplish what you are asking by using any text editor that supports Regex. In this example, I will be using Notepad++. First I will describe what to do, then after I will explain what the Regex does.
Example
- Open the file with
Notepad++
. - Press
Ctrl+F
to bring up theSearch and Replace
window. - Make sure to check the box named
Wrap around
- Select
Regular expression
underSearch Mode
- Under
Find What:
insertName = "(.*)", UniqueId = "(d+)"
- Under
Replace with:
insertName = "$1 $2", UniqueId = "$2"
- Press
Replace all
once.
Understanding the regex
()
these characters represent a group that you want to capture.
$1
represent the first group that you marked with()
$2
same thing but it takes the second group.
d
matchesany digit
.+
after a digit means, match one or more digits.
.
matchesany character
.*
after the dot means match zero or more characters.
In the search example Name = "(.*)", UniqueId = "(d+)"
we have two groups. Matching the content in between the quotes of Name and UniqueId.
In the replace example Name = "$1 $2", UniqueId = "$2"
, we are using these groups to replace what we match with something new. The new is, in this case, the contents of group $1
and group $2
.
add a comment |
You asked the same question on StackOverflow where I just wrote you an answer. I am supplying the same answer here as well.
You can accomplish what you are asking by using any text editor that supports Regex. In this example, I will be using Notepad++. First I will describe what to do, then after I will explain what the Regex does.
Example
- Open the file with
Notepad++
. - Press
Ctrl+F
to bring up theSearch and Replace
window. - Make sure to check the box named
Wrap around
- Select
Regular expression
underSearch Mode
- Under
Find What:
insertName = "(.*)", UniqueId = "(d+)"
- Under
Replace with:
insertName = "$1 $2", UniqueId = "$2"
- Press
Replace all
once.
Understanding the regex
()
these characters represent a group that you want to capture.
$1
represent the first group that you marked with()
$2
same thing but it takes the second group.
d
matchesany digit
.+
after a digit means, match one or more digits.
.
matchesany character
.*
after the dot means match zero or more characters.
In the search example Name = "(.*)", UniqueId = "(d+)"
we have two groups. Matching the content in between the quotes of Name and UniqueId.
In the replace example Name = "$1 $2", UniqueId = "$2"
, we are using these groups to replace what we match with something new. The new is, in this case, the contents of group $1
and group $2
.
You asked the same question on StackOverflow where I just wrote you an answer. I am supplying the same answer here as well.
You can accomplish what you are asking by using any text editor that supports Regex. In this example, I will be using Notepad++. First I will describe what to do, then after I will explain what the Regex does.
Example
- Open the file with
Notepad++
. - Press
Ctrl+F
to bring up theSearch and Replace
window. - Make sure to check the box named
Wrap around
- Select
Regular expression
underSearch Mode
- Under
Find What:
insertName = "(.*)", UniqueId = "(d+)"
- Under
Replace with:
insertName = "$1 $2", UniqueId = "$2"
- Press
Replace all
once.
Understanding the regex
()
these characters represent a group that you want to capture.
$1
represent the first group that you marked with()
$2
same thing but it takes the second group.
d
matchesany digit
.+
after a digit means, match one or more digits.
.
matchesany character
.*
after the dot means match zero or more characters.
In the search example Name = "(.*)", UniqueId = "(d+)"
we have two groups. Matching the content in between the quotes of Name and UniqueId.
In the replace example Name = "$1 $2", UniqueId = "$2"
, we are using these groups to replace what we match with something new. The new is, in this case, the contents of group $1
and group $2
.
edited Dec 20 '18 at 14:33
answered Dec 20 '18 at 14:26
J.A.PJ.A.P
1162
1162
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385414%2fautomate-copying-part-of-a-text-and-paste-it-somewhere-else-on-the-same-line-for%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
that text looks suspiciouly... how to say it... a programmer kinda thing. Does
fgets()
sound familiar to you?, if not, well, I'm sorry, I don't know any Windows program that solves this specific problem. Can you compile code by any chance?– Jenny T-Type
Dec 18 '18 at 5:13
No I can't compile. This example is text from a .cs file but I'm not looking for a programming solution as I have other text files that I want to be able to do the same thing with.
– joetex72
Dec 18 '18 at 6:00
What tools do you have avaliable? cmd, python, bash?
– dmb
Dec 18 '18 at 11:23
Yes I'll try any Windows program, script or app like cmd, Powershell, VBS or download any tool. Not familiar with fgets @JennyT-Type.
– joetex72
Dec 18 '18 at 12:04
fgets()
is a C function that reads a line from a file in put it in a string, I only mention it cause I thought that you might know a little bit of programming, (C is a programming language). I asked you if you can compile cause I was willing to write a program for you to compile in your machine, but setting a cross-compiler just for you, well, not so much. though I'm giving it a though.– Jenny T-Type
Dec 18 '18 at 20:13