Solved

Batch File Delete all files in folder

Posted on 2011-03-21
6
581 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 18

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 18

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

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.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

15 Experts available now in Live!

Get 1:1 Help Now