Skip to content

Instantly share code, notes, and snippets.

@Roald87
Created April 18, 2020 09:23
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Roald87/c68ea920607ec8f32d977d32f3f82712 to your computer and use it in GitHub Desktop.
Save Roald87/c68ea920607ec8f32d977d32f3f82712 to your computer and use it in GitHub Desktop.
Batch script to make hardlinks from a TwinCAT plc project to a Unit test project.
@echo off
title Make hard links from project to test project
echo This script will make hard links of the project files in the POUs folder to the test project folder.
echo Before running this script make sure you already created the neccesarry folder structure in your Plc or TwinCAT project.
for %%i in (.\path\to\project\POUs\*.TcPOU) do (
mklink /H .\path\to\testproject\POUs\%%~nxi %%i
)
pause
@kumaraswamygaviyappa
Copy link

Hello,
Thank you for this batch file.

Is this line needs correction?
Manually add the .TcPOU files to the _MyProject\_Tests_ project

Like this?
Manually add the .TcPOU files to the _MyProject_Tests\Plc\POUs

@Roald87
Copy link
Author

Roald87 commented Jun 30, 2021

Thanks @kumaraswamygaviyappa! Nice catch.

@kumaraswamygaviyappa
Copy link

kumaraswamygaviyappa commented Jun 30, 2021

If the batch file is executed for the second time, Error is generated: A file cannot be created if it already exists.

@Roald87
Copy link
Author

Roald87 commented Jul 1, 2021

Yes that is correct. You only have to link a file once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment