Need to increment filename to DL lot of files

May 15, 2009 at 22:24:26
Specs: Windows Vista
Hi, I lost a ton of pictures. I just remembered I had all of them backed up on my myphotoalbum site... I need to download them all again. I've figured out how to do it manually.

Here is the URL of one of the pictures...

http://bobjoe.myphotoalbum.com/view_photo.php?set_albumName=album63&id=DSC02890&full=true" target="_blank

The filename is the DSC02890 part. If I change it to DSC20891, 892, 893, etc, it will keep on changing the picture, I then right click on the picture and save it.

I accidently lost a ton of pictures a few years back and I had to get them back. I can't remember how I did it, but I wrote a script that kept on incrementing it. It would just keep on incrementing until there were no pictures, then I'd see that the screen would start flashing file not found or something similar and I'd have to break out of the command. But, still beats going to each one individually, right click on the picture and click save.

Does anyone have any clue on how to write the script to download all the files by just writing some while statement or for statement or whatever to keep on incrementing that number forever and then download each picture?


See More: Need to increment filename to DL lot of files

Report •


#1
May 16, 2009 at 02:56:11
That link didn't do anything for me. But as to incrementing numbers, try this:

===========================

<B>:: increment pic num
:: picno Sat 16-05-2009 15:50:31.98

@echo off & setLocal EnableDelayedExpansion

if not %2'==' (
  set start=%1
  set end=%2
  ) else (
    set /p start=low number ?
    set /p end=last number ?
  )
)

for /L %%a in (!start! 1 !end!) do (
  set NUM=%%a
  call :padder
  echo !NUM!
)

goto :eof

:padder
  :loop
    if !NUM:~0^,1! equ 0 (
    set NUM=!NUM:~1^,11!
    goto :loop
    )

  :loop2
    if !NUM:~4^,1!'==' (
    set NUM=0!NUM!
    goto :loop2
    )

goto :eof


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
May 16, 2009 at 06:12:41
(I made a bogus link above for the first part of the URL to keep our family pics private.)

Report •

#3
May 16, 2009 at 06:28:27
Here's how I used what you did and it isn't working yet.

===========================

:: increment pic num
:: picno Sat 16-05-2009 15:50:31.98

@echo off & setLocal EnableDelayedExpansion

if not %2'==' (
set start=%1
set end=%2
) else (
set /p start=low number ?
set /p end=last number ?
)
)

for /L %%a in (!start! 1 !end!) do (
set NUM=%%a
call :padder
echo !NUM!
"http://bobjoe.myphotoalbum.com/view_photo.php?set_albumName=album63&id=DSC!NUM!&full=true"
echo "http://bobjoe.myphotoalbum.com/view_photo.php?set_albumName=album63&id=DSC!NUM!&full=true"
)

goto :eof

:padder
:loop
if !NUM:~0^,1! equ 0 (
set NUM=!NUM:~1^,11!
goto :loop
)

:loop2
if !NUM:~4^,1!'==' (
set NUM=0!NUM!
goto :loop2
)

goto :eof

The output I get when running it is...

C:\Users\Bob Joe\Desktop>batch.bat

C:\Users\Bob Joe\Desktop>increment pic num 0<B 1>::
The system cannot find the file specified.
low number ?02890
last number ?02890
00002
The system cannot find the path specified.
"http://bobjoe.myphotoalbum.com/view_photo.php?set_albumName=album63&id=DSC0000
2&full=true"

C:\Users\bob joe\Desktop>

It didn't even put in my numbers I entered. It put in 00002.


Report •

Related Solutions


Ask Question