?
Solved

batch script - delete existing folder and files prior to moving

Posted on 2011-09-17
4
Medium Priority
?
333 Views
Last Modified: 2012-05-12
i have the following .bat file

@echo off
move C:\myfiles\current\* C:\mybackups\current
move C:\myfiles\current\today C:\mybackups\current
echo COMPLETED!!!
pause
exit

it takes all the .txt files [ C:\myfiles\current\* ]
and my folder and its contents [ C:\myfiles\current\today ]
moves them to [ C:\mybackups\current ]

but if those files already exist in the [ C:\mybackups\current ]
i get an error that it completed the .txt files but cannot move the [ C:\mybackups\current ]
today folder and all its files because it already exists

i need the script to either replace or delete the files in [ C:\mybackups\current ]
prior to moving the files

thanks
0
Comment
Question by:webdott
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 13

Expert Comment

by:5g6tdcv4
ID: 36555463
Are you using move "C:\myfiles\current\today C:\mybackups\current /y "
?
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 2000 total points
ID: 36555521
the first move command will also move the today folder.

If you want remove the backup folder before backing up then you could use

rd /s /q c:\mybackup\current
move c:\myfiles\current c:\mybackups\current

Is that what you mean?

steve
0
 

Author Closing Comment

by:webdott
ID: 36555564
thanks
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36555565
No problem.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Simple Linear Regression
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question