As it says in the title, I have a need to copy a source txt file to any number of tga files that reside within a certain set of subfolders in the directory, where the copies of the txt file have names matching the tga files there. Let's say I have a folder structure looking like this:
destination1/aaa.tga
destination1/bbb.tga
destination2/aaa.tga
otherfolder/ccc.tga
ddd.tga
copyme.txt
So what I want is an end result that's like this, where each new txt file is a copy of copyme.txt
:
destination1/aaa.tga
destination1/aaa.txt
destination1/bbb.tga
destination1/bbb.txt
destination2/aaa.tga
destination2/aaa.txt
otherfolder/ccc.tga
ddd.tga
copyme.txt
I've gotten this code, but I know it's not quite right. The folder variable doesn't get sent to the interior for loop (leaving it searching everywhere in the directory and copying them all to its main folder), and currently any results that would get made with the %%~nxF token wind up as [filename].txt.tga, which is incorrect.
for /d %%G in ("..\materialsrc\VGUI*") do (
SETLOCAL
set folder=%%~nxG
for /r %%F in ("..\materialsrc\%folder%\*.tga") do (
copy "..\materialsrc\VGUIBase.txt" "..\materialsrc\%folder%\%%~nxF.txt"
)
ENDLOCAL
)
I'm sorry if this is an easy thing to do, I couldn't find this specific sort of usage documented anywhere and I'm not super well versed in writing batch files.