1.

Solve : Dos script to copy a file into a subdirectory uniq?

Answer»

Hello,

I need a DOS script to archive my files once daily under a uniquely named subdirectory based on date. I need this file to be backed up every day to a USB (lets call it X:) harddrive from a directory on C: and create a new unique subdirectory daily. Either a sub dir for every month and then a different file name everyday or a sub directory for everyday and then the copied file to each new directory. I only need to copy one file everyday for backup purposes. Can anyone help me with this? I have never wrote anything in dos before. Sorry for a newbie question, but i just dont know. I just knew that most of you guys could bang this thing out in a few minutes. I searched the BOARD but i couldnt find anything that looked relavent (there PROBABLY is i just dont have any knowledge of the syntax), sorry if this is a SUPER newbie question.

THANKS for the help,
Chris

@echo off
for /f "tokens=2-4 delims=/ " %%a in ("%date%") do (
md x:\topleveldirectory\%%c%%b%%a
copy c:\origdir\filename x:\topleveldirectory\%%c%%b%%a
)


NOTES:

Change toplevel directory (2 places) and origdir (1 place) to your situation.

Date will be in yyyymmdd format.

Hope this helps.



Discussion

No Comment Found