Simple batch file to edit .txt files in a folder

Job ID: 32277685

Budget: £10 – £20 GBP

Hi, I need a simple batch file to edit multiple .txt files in a folder. The text files contain hourly stock prices. The stock code (ticker) in each source file is shown as a single digit followed by ".HK". For example: 1.HK, 27.HK, 238.HK, 2347.HK.

I need to convert these stock codes into 4 digits (so need to pad them out with zeros) so the resulting ticker codes would become: 0001.HK, 0027.HK, 0238.HK, 2347.HK etc (so the batch file only needs to process the files which aren't already 4 digits, i.e. from 1-999).

Each file also need to be renamed from "1.HK.txt" to "0001.HK.txt." Examples of before and after files are attached.

Additional notes: The batch file will be used on Windows 10 (and Windows 11 in the future) and should run on a single click without asking for any input from the user. Any kind of compatible batch file will be ok as long as I can edit it in the future (.bat or powershell etc).
Related categories: Data Processing Shell Script Powershell