I'm trying to write a windows batch file that would check which text files are present in folder A and folder B; and if a file is only present in folder A, I want to create a text file with the same name in folder B that would only contain some arbitrary text but not touch the other existing files.
to make things clear
The code should check and see that file1.txt is missing in folder B and create a file with the same name containing the text "Hello World", but not alter in any way the other files.
I know this is going to probably use the if exist and for functions but I can't get my head around it... so far, this is what I've come up with
for %%a in ("%~dp0\folder1\*.*") do if not exist "%~dp0\folder2\%%a" ( echo Hello World )>"%~dp0\folder2\%%a"
EDIT Just adding the solution proposed by McDonald's (not the restaurant) to my puzzle. This just works.
for %%a in ("%~dp0\folder1\*.*") do if not exist "%~dp0\folder2\%%~NXa" ( echo Hello World )>"%~dp0\folder2\%%~NXa"