samedi 5 août 2017

batch crashes on if command

@echo off
set file=%1
set directory=D:\zerobranestudio_lua_IDE\myprograms\love2d-test\
   if not "%file%" == "" (
    if exist %file%\* (
        xcopy "%file%" "%directory%" /E /Y
        RD /S /Q "%file%"
    ) else (
        FOR %%i IN ("%file%") DO (
        set filedrive=%%~di
        set filepath=%%~pi
        )
            if not "%filedrive%%filepath%" == "%directory%" (
            xcopy "%file%" "%directory%" /Y
            DEL /S /Q %file%
            )

    )

) else (
    echo File not specified!
    echo.
    echo Press any key to exit...
    pause >nul
    exit
)

This is the code I've made, it copies a file or a whole directory in D:\zerobranestudio_lua_IDE\myprograms\love2d-test\ when dragged on the batch file.

My problem is that it crashes as soon as I open it. I think it crashes in the 4th line. Is it a problem with the nested if commands?

Any help would be nice. Thanks.

Aucun commentaire:

Enregistrer un commentaire