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
LVL 2
prositAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITCommented:
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

0
David Johnson, CD, MVPOwnerCommented:
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

0
prositAuthor Commented:
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
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

frankhelkCommented:
Why invent the wheel twice ?

You could easily use the free GNU wget (which runs at the command line and is available as Windows port HERE) for recurively downloading all files from an FTP server. If you spawn it from your program and subsequently parse its console output, you should be capable to extract the paths of the successfully d/l'd files and remove them from the server (cam) with little effort.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
frankhelkCommented:
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.
0
prositAuthor Commented:
Just what I was looking for, thank you!
0
prositAuthor Commented:
Do you know how to then delete the remote files?  it seems wget doesn't support it...
0
David Johnson, CD, MVPOwnerCommented:
wget / mget only GETS files you will have to send a del command for each file
0
prositAuthor Commented:
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?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.