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:


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?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

NVITEnd-user supportCommented:
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

Open in new window

David Johnson, CD, MVPOwnerCommented:
Note: Please choose the correct ftp commands to allow the script to work.
open "myservername/serverip"
lcd c:\securityfiles
cd /
mget * /a

Open in new window

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

Open in new window

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.


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...

Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

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.

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
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.
prositAuthor Commented:
Just what I was looking for, thank you!
prositAuthor Commented:
Do you know how to then delete the remote files?  it seems wget doesn't support it...
David Johnson, CD, MVPOwnerCommented:
wget / mget only GETS files you will have to send a del command for each file
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?
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.