I need to rename files based on a matching string in another file : <p>I have a list of files like this</p>

<pre><code>186866-Total-Respondents.csv
343764-Total-Respondents.csv
415612-Total-Respondents.csv
761967-Total-Respondents.csv
</code></pre>

<p>And I want to rename them by matching the first string of numbers above to the same string of numbers in a file called data.txt which is in the same directory.</p>

<p>The contents of data.txt is below</p>

<pre><code>2018-09-Client-1-761967-Brand-1-Total-Respondents
2018-09-Client-1-415612-Brand-2-Two-Total-Respondents
2018-09-Client-1-186866-Brand-Three-Total-Respondents
2018-09-Client-2-343764-Brand1-Total-Respondents
2018-09-Client-3-347654-No-Name-Brand-Total-Respondents
2018-09-Client-3-109321-House-Brand-Total-Respondents
</code></pre>

<p>The end result is that the 4 matching files above will be renamed to</p>

<pre><code>2018-09-Client-1-186866-Brand-Three-Total-Respondents.csv
2018-09-Client-2-343764-Brand1-Total-Respondents.csv
2018-09-Client-1-415612-Brand-2-Two-Total-Respondents.csv
2018-09-Client-1-761967-Brand-1-Total-Respondents.csv
</code></pre>

<p>I have found a <a href="https://stackoverflow.com/questions/24071114/rename-part-of-file-name-based-on-exact-match-in-contents-of-another-file">similar question</a> which uses sed and regex but I can't edit the regex to rename successfully.</p>

<p>I'm guessing that sed or awk would work well here?</p>
