Solved

Batch File Delete all files in folder

Posted on 2011-03-21
6
586 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
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…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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