Solved

Batch File Delete all files in folder

Posted on 2011-03-21
6
582 Views
Last Modified: 2012-05-11
I have a batch file that clears two folders.  It works on some computers but not others.  Can someone tell me what I'm doing wrong and what I can do to make this batch file clear the two folders?  Here are the commands I am currently using:

CD\FT3000
del/q c:\ft3000\*.*
IF EXIST C:\FT3000\*.* DEL C:\FT3000\*.* /Q /F

cd c:\FT3000\DATA
COPY *.* C:\FT3000\Archive\*.*
del/q c:\ft3000\DATA\*.*
IF EXIST C:\FT3000\DATA\*.* DEL C:\FT3000\DATA\*.* /Q /F

thanks.
0
Comment
Question by:BigBobBK
  • 2
  • 2
  • 2
6 Comments
 
LVL 19

Expert Comment

by:Raheman M. Abdul
ID: 35183734
CD c:\FT3000
del/q c:\ft3000\*.*
IF EXIST C:\FT3000\*.* DEL C:\FT3000\*.* /Q /F

cd c:\FT3000\DATA
COPY *.* C:\FT3000\Archive\*.*
del/q c:\ft3000\DATA\*.*
IF EXIST C:\FT3000\DATA\*.* DEL C:\FT3000\DATA\*.* /Q /F
0
 
LVL 19

Expert Comment

by:Raheman M. Abdul
ID: 35183792
CD\FT3000
del/q c:\ft3000\*.*
IF EXIST C:\FT3000\*.* DEL C:\FT3000\*.* /Q /F

cd c:\FT3000\DATA
if exist c:\FT3000\ARCHIVE    COPY *.* C:\FT3000\Archive\*.*
del/q c:\ft3000\DATA\*.*
IF EXIST C:\FT3000\DATA\*.* DEL C:\FT3000\DATA\*.* /Q /F
0
 
LVL 12

Expert Comment

by:Amick
ID: 35183838
DEL /Q /F C:\FT3000\*.*
MOVE C:\FT3000\DATA\*.* C:\FT3000\Archive\
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:BigBobBK
ID: 35188846
I tried both examples but they still are not deleting the files.  Again it works on some XP Pro computers but now on others.  Could it be a file permission's issue or something.  All computers are cloned so they should be identical.
0
 
LVL 12

Accepted Solution

by:
Amick earned 500 total points
ID: 35190503
BigBobBK,

You're absolutely right, identically configured systems should respond in identical ways.

Some questions for you:

Is the file-creating program run under the same account on each machine?  
Is the batch job that is deleting the files run under the same account as the file creator?
Does the DEL /Q /F C:\FT3000\*.* command fail completely or partially?
Does the MOVE command fail completely or partially?
How do you clean up the directories when the batch job fails? (Please provide the specific commands you issue to effect cleanup.)
Is there anything about the Archive data that might be causing a problem?  For example is it possible that you're trying to copy files of the same name to the Archive, resulting in the application balking based on a problem in overwriting the archived file?

Knowing the answer to these questions may help provide a clue to the root cause.
0
 

Author Closing Comment

by:BigBobBK
ID: 35199370
You helped me figure it out.  thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

785 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