Probably it is. But this is not a free script shop. We do not write ready to use Powershell code on request. You will have to write the actual code yourself. If you get stuck on a certain point we’re probably able to help you further.
Regardless of that: Have you tried to search for a solution? There are thousands of examples for tasks like this. Either here or on
Indeed, sir @Olaf . But any help that someone offers, helps others through internet. And at a certain moment you were helped without asking for anything. It’s called progress, and we all need to contribute here.
A friend of mine make for me this script, it is very good. But, to be a complete answer, I have to consider another aspect.
In the case there are more lines, the same number of lines, the same structure, except the strings that needs to be parsing. I believe a Loop is need it !
yes, I did the regex. Because I only know html and regex. I just discovered powershell, I didn’t have the time to learn it.
does anyone know how to solve the second part of my problem? It is not necessarily about helping me, but it’s about the thousands of visitors who will also use this information. It’s about progress.
The problem is that I have 40 lines in the File1.html and 40 lines in File2.html, with the same structure, only the values are different. And my powershell can only parsing one line from file1.html to the file2.html
And I need to make the replacement/parsing to all lines, not just one.
OK, I see what you mean. Actually you’re almost there. You just need a nested loop to process your file2 content for each line of the file1 content … like this:
I think it is absolutely impossible to understand the actual task from reading your initial post.
What you actually want if to replace every occurance of a string or actually of a combination of strings to replace with the according combination of strings from another file with the according index of the occurance.
So replace occurance 1 in file 1 replace with occurance 1 in file 2 and so on.
Your code and your regex are insufficient for this purpose.
At least with the samples you posted it worked with this snippet.
I think it would be more reliable and more rubust to provide the new content with a CSV file instead of cutting strings from another html file. Then you could omit the first part of the script where I create the $NewContentList.
so, @Olaf do you remember what you ask me at the beginning at the first reply?
“Regardless of that: Have you tried to search for a solution? There are thousands of examples for tasks like this. Either here or on…”
Ok, so you know PowerShell, you tried 3 solution, and you still did not resolve the problem. I want you to understand one thing. Internet is for helping people. I will help you, for free, the same I was helped.
I made the same request on other forum, they help me without ask me nothing. Maybe this solution will help you to understand much better the PowerShell.
Of course the internet offers a lot of help and most of it is free of charge. That does not mean that all people willing to help you do not expect you to do your homework. And … if you depend on others you should at least try to make them not do more work than needed and you should follow some general rules.
To avoid people willing to help you make their work twice or more you should at least post the links to the crosspostings you create.
With the sample code you provided in your first post my solution works. If it does not you do something wrong.
Let me try to make this very clear: the purpose of this forum is to teach you to do your own work, notto get someone else to do your work for you.
No one here has any responsibility to provide a complete working solution for your specific problem. If another user does offer you even a partially working solution, you should be grateful and gracious.