Solved How to automatically save files with different names?

July 9, 2014 at 02:51:22
Specs: Windows XP, C2D 1.66 Ghz
I have a text file of URLs, each in the form of:

http://domain.com/a/b/c/d.jpg

I want to download all of these, but save each file under the name:

c_d.jpg

In other words, for each file, I want to save the file under its original filename prefixed by the name of its parent directory.

How would I go about doing this on Windows?

I'm fine with using a command line tool such as wget or curl.

Thanks.


See More: How to automatically save files with different names?

Report •

#1
July 9, 2014 at 03:45:27
✔ Best Answer
::====== script starts here ===============
::
:: getem.bat 2014-07-09 17:23:38.74
@echo off & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=* delims= " %%a in (myfile) do (
set S=%%a
set S=!S:/= !
call :sub1 !S!
echo call wget with !PARENT!_!NAME!
)
goto :eof

:sub1
for %%i in (%*) do (
set PARENT=!NAME!
set NAME=%%i
)
goto :eof
::====== script ends here =================

=====================
M2 Golden-Triangle


Report •
Related Solutions


Ask Question