Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Batch File Delete all files in folder

Posted on 2011-03-21
6
Medium Priority
?
594 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 

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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
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…

670 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