When comparing the file extensions, put the current file's extension in quotation marks as well, like so:
for %%i in (D:\test\*.*) do if "%%~xi" == ".zip" move /Y "D:\test\%%~ni%%~xi""D:\test\complete"
I tested it, and it works fine.
To use a subroutine, try this:
for %%i in (D:\test\*.*) do call :checkextension %%i:checkextensionif "%~x1" == ".zip" move /Y "%~1""D:\test\complete"goto:eof
Note how each file's path (%%i
) is passed as a parameter to the :checkextension
subroutine, which then accesses it as %~1
(or %~x1
when only the extension is needed).