Recently i posted a question about what the variable is of a file which you open with a batch file, which is %1.
I used this, to let my batch file copy %1 to a specific location.
After doing this, debugging and a lot of time, and it actually worked, after debugging it more, adding some features, and some more debugging, it stopped working. This is a snippet, where it seems it goes wrong (i tried @echo on to get my info.)
if not "%1:~-8%"==".package" (
set error=yes
set errmes1=File %1 does not have a .package extension.
goto :errpkg
)
copy "%1" "C:\path_to\folder"
:errpkg
cls
echo %errmes1%
...
(%1=C:\path\to\it\file_something.package)
This is the point were it goes wrong, i guess. Because it ends up with this message. What it SHOULD do, is at if not checking if the file has a .package extension. then, set error=yes, just says what it does, set errmes1 sets an error message. and then the goto just goes to some place in the batch file where it explains what the problem is. (using %errmes1%)
So, that’s it. Here is where it goes wrong. I am 100% sure it has a .package extension. Could anyone help me, to tell me what the problem is?
I seriously wonder how you ever got that to work. The substring syntax only works on environment variables (well, and pseudo-variables such as
%cd%). That means you can dobut not
This wouldn’t even work if you had an environment variable named
%1%.Anyway, the usual idiom to check for the extension of an argument is
So why complicate things more than necessary?