Solved

batch script - delete existing folder and files prior to moving

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

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.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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 …

809 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