Automatically Copy From Drive to Year-Month-Day Folder
Moderator: DosItHelp
Automatically Copy From Drive to Year-Month-Day Folder
I'm thinking this will need a helper program to detect media insertion, but here's the problem.
Every day, there is 1 CD and 2 Floppy disks of data that need to be archived to a hard drive. After they have been properly archived, the media needs to be erased.
I want a batch file that will detect the media (helper program may be needed for this), copy the files, compare them, and then delete them if the compare was successful. This batch will probably be run under win95/98 unless something higher is needed.
Any ideas on how to approach this appreciated. The main areas I'm unsure about are the media detection and a good algorithm to make sure the files are copied correctly before deletion.
Every day, there is 1 CD and 2 Floppy disks of data that need to be archived to a hard drive. After they have been properly archived, the media needs to be erased.
I want a batch file that will detect the media (helper program may be needed for this), copy the files, compare them, and then delete them if the compare was successful. This batch will probably be run under win95/98 unless something higher is needed.
Any ideas on how to approach this appreciated. The main areas I'm unsure about are the media detection and a good algorithm to make sure the files are copied correctly before deletion.
-
- Posts: 82
- Joined: 30 Dec 2013 10:16
- Location: United States by the big waterfall
Re: Automatically Copy From Drive to Year-Month-Day Folder
You can do the insertion detection using WMIC or FSUTIL but I don't think either of them are available until Winxp. Also, where do you get those floppy disks? I thought they stopped making them a few years ago.
Show an example of the file names for the second part. I recently wrote a script that does what you want almost exactly.
Show an example of the file names for the second part. I recently wrote a script that does what you want almost exactly.
Re: Automatically Copy From Drive to Year-Month-Day Folder
Yeah, I think those are part of xp. I'd rather not depend on anything in the OS though. A stand-alone exe that did the detection as part of the batch would be preferable. This would also allow it to run on some of our older win9x boxes that do small tasks like this.Matt Williamson wrote:You can do the insertion detection using WMIC or FSUTIL but I don't think either of them are available until Winxp. Also, where do you get those floppy disks? I thought they stopped making them a few years ago.
Show an example of the file names for the second part. I recently wrote a script that does what you want almost exactly.
I'm not sure what the source file names will be, but the copy part would be basically
Code: Select all
xcopy DRIVE:\ ARCHIVE DRIVE:\ARCHIVE\YEAR\MM\DD\ /f/r/e/s/h/k/y/d/c
Re: Automatically Copy From Drive to Year-Month-Day Folder
Samir wrote:Every day, there is 1 CD and 2 Floppy disks of data that need to be archived to a hard drive. After they have been properly archived, the media needs to be erased.
I want a batch file that will detect the media (helper program may be needed for this), copy the files, compare them, and then delete them if the compare was successful.
Are there any more copies of the files other than the ones being made on the hard drive?
I am pretty sure that Win95/98 can't erase a cd even if it is a cd-rw.
Re: Automatically Copy From Drive to Year-Month-Day Folder
Maybe the Cdrtools suite is able to erase a cd-rw.
I've seen (unofficial) binaries of Cdrtools (in the past) even for for MS-DOS 6.22, and i assume there are (probably unofficial) releases for win95/98.
You "only" have to find these binaries, or download the sources (if still available; not tested) of the components listed at http://cdrecord.org and compile them.
penpen
I've seen (unofficial) binaries of Cdrtools (in the past) even for for MS-DOS 6.22, and i assume there are (probably unofficial) releases for win95/98.
You "only" have to find these binaries, or download the sources (if still available; not tested) of the components listed at http://cdrecord.org and compile them.
penpen
Re: Automatically Copy From Drive to Year-Month-Day Folder
No, the files copied to the hard drive would be the only ones after the originals are erased.foxidrive wrote:Samir wrote:Every day, there is 1 CD and 2 Floppy disks of data that need to be archived to a hard drive. After they have been properly archived, the media needs to be erased.
I want a batch file that will detect the media (helper program may be needed for this), copy the files, compare them, and then delete them if the compare was successful.
Are there any more copies of the files other than the ones being made on the hard drive?
I am pretty sure that Win95/98 can't erase a cd even if it is a cd-rw.
I hoping that there may be an application for the win95/98 that can erase a cd, but if not, it's not a dealbreaker. Those things are cheap enough these days to not be a requirement for the batch.
Re: Automatically Copy From Drive to Year-Month-Day Folder
Thank you very much for the references. I was able to search and find various different dos/windows command line ways to erase the cdrw. I haven't tested any of them yet, but they all look very promising.penpen wrote:Maybe the Cdrtools suite is able to erase a cd-rw.
I've seen (unofficial) binaries of Cdrtools (in the past) even for for MS-DOS 6.22, and i assume there are (probably unofficial) releases for win95/98.
You "only" have to find these binaries, or download the sources (if still available; not tested) of the components listed at http://cdrecord.org and compile them.
penpen
Re: Automatically Copy From Drive to Year-Month-Day Folder
You may use the autorun option of win9x to detect if a media is inserted (but you need control about the cd content).
I'm not sure if autorun is enabled, or could be enabled for fdds, but this is possible for cd/dvd/.... .
Just create a "autorun.inf" in the root of the cd similar to this (Edit: corrected the code):
You also may add something like a "gatekeeper" environment variable to prevent the call of the batch file in most other pc's:
cmd.exe ... "if defined backupdevice C:\your\backup\batch.bat"
Another option is, to test for a specific file on the disk, when you manually start your backup batch.
If you need to create a current date folder you may do something like this:
You may need to adjust the the name "Current.bat" if the first word of the "date" command output changes:
penpen
Edit 1: I've corrected the line ">Current.bat echo:@echo:%%4": "@echo" -> "set today="
Edit 2: Added the last section.
I'm not sure if autorun is enabled, or could be enabled for fdds, but this is possible for cd/dvd/.... .
Just create a "autorun.inf" in the root of the cd similar to this (Edit: corrected the code):
Code: Select all
[autorun]
open=C:\Windows\system32\cmd.exe ... args... C:\your\backup\batch.bat
You also may add something like a "gatekeeper" environment variable to prevent the call of the batch file in most other pc's:
cmd.exe ... "if defined backupdevice C:\your\backup\batch.bat"
Another option is, to test for a specific file on the disk, when you manually start your backup batch.
If you need to create a current date folder you may do something like this:
Code: Select all
@echo off
>return.txt echo:
>Current.bat echo:@set today=%%4
type return.txt | >toDate.bat date
call toDate.bat
del toDate.bat
del Current.bat
del return.txt
echo today=%today%
You may need to adjust the the name "Current.bat" if the first word of the "date" command output changes:
Code: Select all
Current date is Mon 16.03.2015
Enter new date (dd-mm-yy):
penpen
Edit 1: I've corrected the line ">Current.bat echo:@echo:%%4": "@echo" -> "set today="
Edit 2: Added the last section.
Last edited by penpen on 15 Mar 2015 18:59, edited 1 time in total.
Re: Automatically Copy From Drive to Year-Month-Day Folder
Samir wrote:No, the files copied to the hard drive would be the only ones after the originals are erased.foxidrive wrote:Are there any more copies of the files other than the ones being made on the hard drive?
Oh, ok. They must be unimportant files then.
But don't mind me, I'm a bit of a backup nazi.
Re: Automatically Copy From Drive to Year-Month-Day Folder
I won't be able to put anything on the source media since it will be coming from another system. That's an interesting batch for the date.penpen wrote:You may use the autorun option of win9x to detect if a media is inserted (but you need control about the cd content).
I'm not sure if autorun is enabled, or could be enabled for fdds, but this is possible for cd/dvd/.... .
Just create a "autorun.inf" in the root of the cd similar to this:Code: Select all
[autorun]
open=C:\Windows\system32\cmd.exe ... args... C:\your\backup\batch.bat
You also may add something like a "gatekeeper" environment variable to prevent the call of the batch file in most other pc's:
cmd.exe ... "if defined backupdevice C:\your\backup\batch.bat"
Another option is, to test for a specific file on the disk, when you manually start your backup batch.
If you need to create a current date folder you may do something like this:Code: Select all
@echo off
>return.txt echo:
>Current.bat echo:@echo:%%4
type return.txt | >toDate.bat date
call toDate.bat
del toDate.bat
del Current.bat
del return.txt
echo today=%today%
penpen
Re: Automatically Copy From Drive to Year-Month-Day Folder
I noticed that my date batch was wrong and corrected it:
The environment variable "today" should have been set to the date, instead of echoing it in Current.bat.
penpen
The environment variable "today" should have been set to the date, instead of echoing it in Current.bat.
penpen
Re: Automatically Copy From Drive to Year-Month-Day Folder
That makes more sense now. I was having some trouble following the batch, but know that you know a lot more about batch than I do, so I was assuming it would work.penpen wrote:I noticed that my date batch was wrong and corrected it:
The environment variable "today" should have been set to the date, instead of echoing it in Current.bat.
penpen