@echo off
REM Version: 1.1
REM Copies all dynamo files from subfolders to a selected folder
REM Created by Peter Gyetvai: gyetpet@mailbox.org
REM
REM Usage: 
REM     DynamoPlayerInstaller <folder>
REM Folder: The folder you set up for dynamo player. Default: Documents\DynamoPlayer

chcp 1250
setlocal enabledelayedexpansion

IF [%1]==[] (
    SET FOLDER=%UserProfile%\Documents\DynamoPlayer
) ELSE ( 
    SET FOLDER=%1
)

IF NOT EXIST %FOLDER% (
   md %FOLDER%
) ELSE (
    del /Q %FOLDER%\*
)

cd "%~dp0"

(for /D %%f in (*) do (
    set extra=
    IF %%f==nodes set extra=True
    IF %%f==src set extra=True
    IF %%f==WIP set extra=True
    
    if not DEFINED extra (
        call :filecheck "%%f"
    )   
))

EXIT /B

:filecheck 
    set thefolder=%1
    for /R %thefolder% %%h in (*.dyn) do (
        echo %%h   
        copy /y "%%h" "%FOLDER%" 
    )

EXIT /B