This is my code, I drag and drop several images at one to compress all of them.
if [%1]==[] goto :eof
:loop
start %~dp0ImgCompress.exe %1
shift
if not [%1]==[] goto loop
It’s works well for the first file, but at the 2nd and beyond the relative path (%~dp0) becomes the relative path of the files I drag and drop. My thought is that the %~dp0 was the relative path of the executing file. Any idea how to overcome this problem?
The path to your batch file is %0. Shift makes that %1 becomes %0. To solve you problem save %~dp0:
And use it later: