Solved

Batch File Delete all files in folder

Posted on 2011-03-21
6
579 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

20 Experts available now in Live!

Get 1:1 Help Now