Solved

batch script - delete existing folder and files prior to moving

Posted on 2011-09-17
4
327 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
  • 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now