Kategori arşivi: Windows

windows cmd bat file pass parameter sample

CopyFile.bat –>

@echo off
set param=%2
set argv1=%~dpnx1
set argv2=%~dpnx3
if %param% EQU -copy (
    if "%argv1%" NEQ "" if "%argv2%" NEQ "" (
        for %%a in ("%argv1%") do (
            if not exist "%argv2%" mkdir "%argv2%"
            copy /y %%a "%argv2%">Nul
        )
    echo( Finish Copy [%argv1%] to [%argv2%]
    ) else echo( You need 3 argument!
) else echo( Wrong argument : %param%
pause>Nul
exit

And run it with command:

CopyFile.bat "nameoffile" -copy "C:\Example"