@echo off
REM Version: 1.0
REM Copies all dynamo files from subfolders to a selected folder
REM Created by Peter Gyetvai: gyetpet@gmail.com
REM
REM Usage: 
REM     DynamoPlayerInstaller <version> <folder>
REM Version: then dynamo version to copy. Possible values: 1, 2. Default: 2
REM Folder: The folder you set up for dynamo player. Default: Documents\DynamoPlayer

chcp 1250
setlocal enabledelayedexpansion

IF [%1]==[] (
    SET VERSION=2
) ELSE ( 
    SET VERSION=%1
)

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

IF NOT EXIST %FOLDER% (
   md %FOLDER%
) 

cd "%~dp0"

(for /D /r %%f in (%VERSION%*x) do (
   call :filecheck "%%f"
))

EXIT /B

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