Solved

batch script - delete existing folder and files prior to moving

Posted on 2011-09-17
4
332 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Six Sigma Control Plans

728 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