General discussion

Locked

Moving files daily

By whatnetever ·
Hi everyone,

I need to move some daily files to its final destination (sorted by dates) every day. Is there any way to do it automatically? Right now I'm doing a batch file for every single day because the folder name is different. It's kind of hard because I have to do a batch file for each day of the month...

Thanks for your help.

Scotch

This conversation is currently closed to new comments.

13 total posts (Page 1 of 2)   01 | 02   Next
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Moving files daily

by Joseph Moore In reply to Moving files daily

I should be able to write up a BAT file that will do this, but I need to know a few things first.
You have a folder for each day of the month, right? What are the folders named? 01, 02, 03, 04 etc???

Next, are the files that you are moving namedwith date-sensitive names, or are they static file names?

Please post an example of what you are doing, and I can write up a BAT file to do the whole thing, I hope!!!!

Probably.

Collapse -

Moving files daily

by Joseph Moore In reply to Moving files daily

Hello. I am including my BAT file suggestion for you below. I tried it out on my XP machine while on the train last night. Worked just fine. I moved dozens of files into the correct locations all without a hitch. I also changed the date on my laptopto make sure that works also, and it did.
The only thing to keep in mind is that when it tries to make the directories, you will get an error if they already exist. "A subdirectory or file already exist". No biggie. It doesn't stop anything from working. You could just REM out the directory creation after you have all 31 numerical subfolders under the C:\CAMERA directory created, but it does no harm leaving it in. Other then that, it works like a champ.

Collapse -

Moving files daily

by Joseph Moore In reply to Moving files daily

@echo off

REM ************************************
REM Camera archiving per date
REM This file will create a folder structure based on the day of the month
REM that this file is run. Under the C:\CAMERA folder there will be one subfolder
REM ranging from 1-31, representing the day of the month the camera images
REM were recorded. After that, folders for each camera are made. Lastly, the images
REM from each camera are moved from the FTP location to the appropriate camera
REM folder under the correct date. Then, during the following month, the previous
REM month's images are deleted before archival of the current day's images is done
REM to prevent keeping old images that are not needed
REM ************************************

cls

REM ************************************
REM Set environment variable to determine the current date
REM Used to create subfolders to organize files for each camera
REM ************************************
for /f "tokens=1-3 delims=/ " %%i in ('date /t') do set today=%%k

REM ************************************
REM Deletes last month's pictures
REM ************************************
del d:\cameras\%today%\cam1\*.* /q
del d:\cameras\%today%\cam2\*.* /q
del d:\cameras\%today%\cam3\*.* /q

REM ************************************
REM Create subfolders under C:\Camera folder for archival storage
REM One folder per camera, all under a 2-digit numbered folder representing the day
REM of the month the pictures were taken
REM ************************************
md d:\cameras\%today%\cam1
md d:\cameras\%today%\cam2
md d:\cameras\%today%\cam3

REM ************************************
REM Move pictures from FTP to the appropriate subfolder per camera
REM ************************************
move /y d:\ftp\cam1\*.* d:\cameras\%today%\cam1
move /y d:\ftp\cam2\*.* d:\cameras\%today%\cam2
move /y d:\ftp\cam3\*.* d:\cameras\%today%\cam3

Collapse -

Moving files daily

by Joseph Moore In reply to Moving files daily

REM ************************************
:eof
REM ************************************

REM ************************************
REM File by Joseph Moore 04/02/2003
REM ************************************

EXIT

Collapse -

Moving files daily

by Joseph Moore In reply to Moving files daily

Ok, that's it.

Hope this helps

Collapse -

Moving files daily

by whatnetever In reply to Moving files daily

Thanks so much, Joseph! :-) Works beautifully.

Collapse -

Moving files daily

by whatnetever In reply to Moving files daily

Here is an example we did:

del d:\cameras\10\cam1\*.* /q
del d:\cameras\10\cam2\*.* /q
del d:\cameras\10\cam3\*.* /q
move /y d:\ftp\cam1\*.* d:\cameras\10\cam1\
move /y d:\ftp\cam2\*.* d:\cameras\10\cam2\
move /y d:\ftp\cam3\*.* d:\cameras\10\cam3\

The 'del' deletes the previous month's info. Then the 'move' moves the picture files from ftp folder to the permanent folder to keep for a month. These are files from the cameras in the office. The file names are dated like this: '2003040118312201' (I think it's year, month, date, hour, minute, second, and then something... The pictures are taken every 10 seconds). The permanent folders' names are from 1 (not 01) all the way to 31. Currently we're making a new script every day and put it in the scheduled task at the end of the day to move the files... Kind of time consuming.

I hope this helps. Please let me know if more info is needed. Thanks a million!

Scotch

Collapse -

Moving files daily

by DRiv In reply to Moving files daily

Scotch,
Please list out what version of Windows you are using to COPY, since I have scripts that vary by version due to great little changes that occur and some programs that don't run in WinNT. I personally use an old 'dedicated' robot computer that runs Win98 (due to all the nice 'old' DOS programs that run still!).

Collapse -

Moving files daily

by whatnetever In reply to Moving files daily

Poster rated this answer

Collapse -

Moving files daily

by whatnetever In reply to Moving files daily

I modified the permanent folder names to two digits (so now it's 01 instead of 1). Also, the day setting on the computer is US settings, so today's date is: Wednesday, April 02, 2003. Hope this helps.

I am using Windows 2000.

Thanks!

Back to Windows Forum
13 total posts (Page 1 of 2)   01 | 02   Next

Related Discussions

Related Forums