In the Python Scrapy framework there is a scrapy.bat file:
@echo off
setlocal
"%~dp0..\python" "%~dp0scrapy" %*
endlocal
Could someone explain what this does? Especially this line "%~dp0..\python" "%~dp0scrapy" %*
.
In the Python Scrapy framework there is a scrapy.bat file:
@echo off
setlocal
"%~dp0..\python" "%~dp0scrapy" %*
endlocal
Could someone explain what this does? Especially this line "%~dp0..\python" "%~dp0scrapy" %*
.
You want to know primarily what %~dp0
means; for that, try taking a look at What does %~dp0 mean, and how does it work? (Remember to search for such things. Search is good.)
Once you understand what %~dp0
means, the rest is easy, but you can get it spelled out by turning a command into an echo
statement—echo "%~dp0..\python" "%~dp0scrapy" %*
. This is a handy technique in batch file comprehension; poor man's variable inspection.
As for setlocal
and endlocal
, try (a) help
and (b) the power of search.
This is batch syntax. %0
is the first argument which is the path name of the current batch file. ~dp is for path manipulation and means drive and path. In effect, it launches python from a folder up(%~dp0..
) and load scrapy module. The %*
means pass other arguments passed to the batch to the script.