Link to home
Start Free TrialLog in
Avatar of prosit
prositFlag for United States of America

asked on

DOS FTP

Hello,

I have a security camera that records on motion detect and the way I get it off the camera is either to take the SD card out and copy it or I can FTP to it.

I'd like to create a dos program that automatically grabs the video, but I can't find a good way to iterate through the directories.

The structure is as follows:

/IPCamera/FI9821W_00626E53BD32/record/20150621
/IPCamera/FI9821W_00626E53BD32/record/20150622
/IPCamera/FI9821W_00626E53BD32/record/20150623
etc.

Inside each of these directories there's another directory with a time-stamp "20150621_020331" in which the files are placed.

Any clever way of doing this?

tnx
~j
Avatar of NVIT
NVIT
Flag of United States of America image

Do you want to copy the files without removing the card from the camera, i.e. via ftp? For that, you can use an ftp command-line script.

If you remove the card and connect the card to a computer, that gives the card a drive letter. Then, you can use a .bat file to copy the files.

In the folder structure you show, do you want to copy just the files, but not the folders? I assume you don't want to use Windows Explorer to traverse the folders then finally get to the files.

What are the files named like?

Assuming all the filenames are unique, you could copy all the files to one folder.
- Save below code to a .bat file, e.g. FindFiles.bat
- Note: The COPY command overwrites target duplicates
- Change following to your needs: srcdir, tgtdir

@echo off
set srcdir=c:\local\temp
set tgtdir=C:\Local\test\Target
pushd %srcdir%
for /f %%a in ('dir /s /a-d /b *.*') do (
  copy /y "%%a" "%tgtdir%">nul
)
popd

Open in new window

Note: Please choose the correct ftp commands to allow the script to work.
runftp.txt
open "myservername/serverip"
"%username%"
"password"
lcd c:\securityfiles
cd /
bin
hash
mget * /a
bye

Open in new window

getfiles.bat
"c:\windows\system32\ftp.exe -s:runftp.txt"

Open in new window

Avatar of prosit

ASKER

NewVillage...  I definitely wanted to avoid doing the SD card; the FTP method was what I'm looking for, sorry if that was unclear.

David,

When running it as is, I get the following result, note that there were three directories under the folder "record":

230 OK. Current directory is /
ftp> lcd E:\AutoVideo
Local directory now E:\AutoVideo.
ftp> cd ipcamera
250 OK. Current directory is /IPCamera
ftp> cd FI9821W_00626E53BD32
250 OK. Current directory is /IPCamera/FI9821W_00626E53BD32
ftp> cd record
250 OK. Current directory is /IPCamera/FI9821W_00626E53BD32/record
ftp> bin
200 TYPE is now 8-bit binary
ftp> hash
Hash mark printing On  ftp: (2048 bytes/hash mark) .
ftp> mget * /a
200 TYPE is now 8-bit binary
ftp> bye
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.

Open in new window


I tried fiddling with it and use MGET -rf * which seems to want to start copying files but it can only download files not directories.

And to make it worse, I'd also like to delete the files when they're deleted.   I'm almost at a point where writing a program might be easier...

~j
ASKER CERTIFIED SOLUTION
Avatar of Frank Helk
Frank Helk
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
P.S.: Wget supports mangling with the contents of remote ftp sites as well - if told to do so, it leaves raw listings of remote directoy content behind which could be parsed to i.e. remove remote files with FTP commands.
Avatar of prosit

ASKER

Just what I was looking for, thank you!
Avatar of prosit

ASKER

Do you know how to then delete the remote files?  it seems wget doesn't support it...
wget / mget only GETS files you will have to send a del command for each file
Avatar of prosit

ASKER

And then I'm back to square 0 since I'd now have to write something to delete the files...

I did read something about a patch that would allow wget to do so, do you know anything about that?