Batch: Deleting A System Generated Folder.

November 19, 2010 at 15:11:33
Specs: Windows 2000 Pro, AMD Semperon 2500+ / 2GB
have a “black box” unit in a vehicle that records digital video onto an SD Card. At the end of each day, the data on the SD Card is to be copied/archived onto a computer’s internal Slave Drive, then the data files contained in the folder “EventList” is to be deleted, while the entire folder and files contained in “FileList … [date/time]”) are to be deleted. Thus, leaving the SD Card will be free to be recorded upon the following day.

Therefore, I want to create a batch file that will accomplish the following tasks:

1) Create a new subfolder on a fixed slave drive [E:\], and name it with the current day’s date (e.g., 11192010)

2) Copy the entire contents of an SD Card [F:\] (i.e., all files and folders) to the newly-created subfolder on the fixed slave drive [E:\].

3) Delete all the files within a folder titled “EventList” on the SD Card [F:\], so that it becomes an empty folder.

4) Completely delete the second folder on the SD Card, which is automatically created/named each day by the hardware (e.g., “FileList_20101117_191021”); this hardware generated name is a combination of the date and time.

I’ve been able to create a batch file that accomplishes the first three tasks, but don’t know how to do the final task (#4 above), since the generated folder name is continually different. Here’s what I have so far:

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

@echo off
for /F " tokens=1,2,3* delims=/, " %%i IN ('date /T') DO (
set CUR_DAY_OF_WEEK=%%i
set CUR_MONTH=%%j
set CUR_DAY=%%k
set CUR_YEAR=%%l)

for /F " tokens=1,2,3* delims=:, " %%i IN ('time /T') DO (
set CUR_HOUR=%%i
set CUR_MIN=%%j
set AM_PM=%%k)

MD "e:\blackbox\ford2000\%CUR_MONTH%%CUR_DAY%%CUR_YEAR%

xcopy "f:\" "e:\blackbox\ford2000\%CUR_MONTH%%CUR_DAY%%CUR_YEAR%" /D /E /C /R /I /K /Y

echo y | del f:\EventList\*.*

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

The contents of the SD Card (F:\) are as follows:

Folder: ”EventList” … {this needs to remain, after moving files to E:\blackbox\ford2000\CurrentDate}
Folder: ”FileList_20101117_191021” (generated name) …{this folder and all it’s files need to be deleted}
File: “drs_config” … {this needs to remain, after being copied to slave drive E:\blackbox\ford2000\CurrentDate}
File: “GpsInfo” … {this needs to remain, after being copied to slave drive E:\blackbox\ford2000\CurrentDate}

I was thinking that targeting for deletion folders with the current day’s date as it’s creation date might be the easiest way to do it, as the “EventList” maintains it’s creation date of 11/17/2010, while the “FileList” folder changes each day – the date for the files “drs_config” and “GpsInfo” also changes each day.


Can someone please help me with the final line in the batch file, that will allow me to delete the generated “FileList_(date/time)” folder and all of it’s contents? I would very much appreciate the assistance.

Thank you,

Dina Miles


See More: Batch: Deleting A System Generated Folder.

Report •

#1
November 19, 2010 at 16:41:40
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b/s/ad f:\filelist*.*') do (
rd /s /q %%a
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
November 21, 2010 at 13:02:47
Dear Mechanix2Go,

Thank you so much, it worked perfectly! Have a great week!!

~ Dina Miles


Report •

#3
November 22, 2010 at 12:15:40
You can save some lost motion by using xcopy to create a matvhing folder. And avoid the possibility of getting "yesterday's" files in "today's" folder.

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

@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b/s/ad f:\filelist*.*') do (
xcopy %%~DPNa e:\%%~Na\ /s
rd /s /q %%a
)


=====================================
Life is too important to be taken seriously.

M2


Report •

Related Solutions

#4
November 23, 2010 at 11:50:11
Out of sheer curiosity and because this is something I've always had an interest in doing - what is this black box you have setup? Is it something off the shelf or something you've personally created? Recording actual video/audio or just speed and car data?

Sounds really interesting :)


Report •

#5
November 24, 2010 at 05:17:09
Dear Mechanix2Go,

Again, thank you very much for the new copying command! It never even occurred to me that I might run into the issue you pointed out. Have a wonderful Thanksgiving!!

~ Dina Miles


Report •

#6
November 24, 2010 at 05:59:02
Dear Viddywell,

The "black box" unit that I am using is called the "Carpa-120". It, like many other similar units, is made in Asia. Unfortunately, the website for the online company from which I purchased the unit is no longer up. However, you might be able to find someone who now carries it by doing an internet search. Alternatively, the manufacturer might be able to direct you to another reseller. Here is the manufacturer's website that I got off the box that the Carpa-120 came in, which has an option to view the website in English:

http://www.dstelecom.co.kr/

On the website, you can see not only the specifications of the Carpa-120, but also view a sample of recorded video, and see how to it is installed. You can choose to power it either by your car's cigarette lighter or purchase an optional cable to have it run off your car's engine. I chose the latter and had an auto mechanic do the installation. The audio and video are very clear. It has two cameras: one for the driver's view, and one for the inside of your car. It records onto an SD card, which allows you to transfer the recorded files to a computer for viewing and/or archiving, as well as many other features, such as G-force monitoring and allowing you to see your route in real time playback with Google maps. It comes with a 2GB/class 6 SD card, but you can replace that with up to a 32 GB. A 2GB will get you one hour and twenty minutes of recording time; 4GB is three hours; 8GB six hours, etc. You can set the Carpa-120 to either record continuously, once it it powered on, or only record if the engine is on. It records in three minute blocks, which creates video files of approximately 23GB in size -- you have the option of only recording the driver's view. If the capacity of the installed SD card is reached, the Carpa-120 will then begin overwriting the earliest video files on the SD card. I am very pleased with it. I hope this has helped to answer your question.

~ Dina Miles


Report •

Ask Question