开发者

Windows Batch Filesystem Backup

开发者 https://www.devze.com 2023-03-19 07:23 出处:网络
Update: Ehh -- Even though this question isn\'t \"answered\", I\'ve just emptied my pockets and purchased an SSD.My ramdisk software was going to cost just about as much anyway.I\'m not particularly

Update:

Ehh -- Even though this question isn't "answered", I've just emptied my pockets and purchased an SSD. My ramdisk software was going to cost just about as much anyway. I'm not particularly interested in an answer here anymore, so I'll just mark this as "answered" and go on with my life.

Thanks for the help.


I've got a program which is writing files to a ramdisk (in Windows XP) and I need to copy its data from the ramdisk to a directory on my harddrive once it has finished execution. Obviously in a ramdisk the space is limited and I need to free up as much space on the ramdisk as I can between runs. The simple solution is to copy the data folder that my program generates on the ramdisk to a location on the harddisk and recursively delete the "data" folder from the ramdisk.

There is a problem with开发者_C百科 that solution however; my program looks at the filesystem and filenames to ensure that it doesn't overwrite files (The most recent data file in the directory is 006.dat, so it will write 007.dat instead of overwriting anything). I can't just delete the files once I'm done writing data because it needs that filesystem intact to record data without over-writing the old files when I copy the data back to my hard-drive

I'd like a simple little windows batch script which I can execute after my program has finished writing data files to the ramdisk. This batch script should copy the ramdisk "data" folder to my harddisk and delete all the files from the ramdisk, then it should re-create the filesystem as it was but with all zero-byte files.

How would I go about this?


Could you simply have it delete all files EXCEPT the most recent, then you would still have 006 and your logger would generate 007?

That seems safer than creating a zero length file because you would have to make sure it wasn't copied over the real 006 on the backup.

edit: Sorry can't help with how to do this solely in batch, but there are a bunch of unix utils, specifically find and touch that are perfect for this. There are numerous windows ports of these - search on SO for options.

Robocopy.exe (free download in the windows server resource kit) can do copy from one dir to another AND has the option to watch a dir for new files and copy them when they are closed or changed

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号