@echo off
SETLOCAL EnableDelayedExpansion
REM Dwg import template copier
REM Copies and renames the default rfa file to all dwg files in the folder. 
REM Current revit file is for revit 2019
REM Created by Peter Gyetvai: gyetpet@gmail.com

REM ---------
REM VARIABLES
REM ---------

SET FILEEXT=dwg
SET TEMPLATEFILENAME=Detail_empty

REM -----------------------
REM Beginning of the script
REM -----------------------

for /R "%~dp0" %%f in (*.%FILEEXT%) do (
    echo processing: %%f
        
    copy "%~dp0\%TEMPLATEFILENAME%.rfa" "%~dp0%%~nf.rfa"
    echo "%~dp0%%~nf.rfa">> "%~dp0filelist.txt"
)

REM -----------------
REM End of the script
REM -----------------