[SOLVED] How to get filename from URL and set it to variable?
Posted: 11 Aug 2020 05:27
Hello,
In a batch file, I need to rip the filename from a URL, and set it to variable.
This doesn't work ("| was unexpected at this time."):
Do you know of a solution, using either cmd, GNU grep/sed/awk?
Thank you.
In a batch file, I need to rip the filename from a URL, and set it to variable.
This doesn't work ("| was unexpected at this time."):
Code: Select all
REM Usage: mybatch.bat http://www.acme.com/myfile.html → extract "myfile.html"
REM OK echo %1 | sed "s/.*\///"
for /f %%i in ('echo %1 | sed "s/.*\///"') do set FILENAME=%%i
echo %FILENAME%
Thank you.