ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

how to creating a batch file which......



  E39 530i
copies all files and folders including sub-directories to a new folder on a different drive? What i want to do is backup the contents of my documents on a daily basics to a new drive, but on the new drive i would like the batch to be place the backups within a folder called monday_backup, tuesday_backup etc etc depending on what day the backup were ran.

Hope this makes sense I can't remember for the life of me how to write the script. :S :eek: :mad: :mad: :mad: :mad: :mad:
 
  Cupra
Code:
@echo off
for /F "tokens=1-4 delims=/ " %%I in ('date /t') do (
set DayOfWeek=%%I
set Month=%%J
set Day=%%I
set Year=%%K
set Date=%%I %%J/%%K/%%L
)
mkdir "D:\\XXX\xx\Backup\%Year%%Month%%DAY%"

copy C:\XXX\XX\*.* "D:\\XXX\xx\Backup\%Year%%Month%%DAY%"

Change the directory paths as you need... the date/ month can also be changed to the format you want
 
  E39 530i
@echo off
for /F "tokens=1-4 delims=/ " %%I in ('date /t') do (
set DayOfWeek=%%I
set Month=%%J
set Day=%%I
set Year=%%K
set Date=%%I %%J/%%K/%%L
)
mkdir "D:\\XXX\xx\Backup\%Year%%Month%%DAY%"

copy C:\Documents and Settings\JSW\My Documents\phone system\*.* "D:\\XXX\xx\Backup\%Year%%Month%%DAY%"

made the following changes within the script, but something is not right? It creates the XXX\xx\Backup\20070529 directory on the d: drive but it doesn't copy the content and sub directories with C:\Documents and Settings\JSW\My Documents\phone system. What the hell am i doing wrong? lol.
 
  Cupra
Put brakets around the C:\Documents and Settings\JSW\My Documents\phone system\*.* perhaps?:

copy "C:\Documents and Settings\JSW\My Documents\phone system\*.*" "D:\\XXX\xx\Backup\%Year%%Month%%DAY%"
 
  E39 530i
excellent that now works! how do i get it to place the files in a folder called monday_backup tuesday_backup etc etc depending on when batch file was ran?
 


Top