Solved

batch script - delete existing folder and files prior to moving

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

914 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

13 Experts available now in Live!

Get 1:1 Help Now