Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Subject: Deleting a created file

Original Message
Name: smartguy2020
Date: May 9, 2008 at 06:49:39 Pacific
Subject: Deleting a created file
OS: WinXP
CPU/Ram: Intel core 2 duo/ 2 gb
Model/Manufacturer: custom/custom
Comment:
I have created a folder with a batch file that names the folder by the current date i.e. yyyymmdd. I need to be able to delete this folder on a daily basis and am having problems writing the batch file that would do this. This is the code I have that creates the folder:

@echo off
cd c:\temp
set folder=%date:~10,4%%date:~7,2%%date:~4,2%
mkdir %folder%
move c:\temp c:\%folder%

Any suggestions would help tremendously. I feel like a fly who has flown into a sticky wall of stupid!!! Please Help!


Report Offensive Message For Removal

Response Number 1
Name: IVO
Date: May 9, 2008 at 12:25:46 Pacific
Subject: Deleting a created file
Reply: (edit)
What do you mean by "I need to be able to delete this folder on a daily basis"?

More, from your code the folder is created as a subfolder of C:\temp , i.e. C:\temp\yyyymmdd, as you issue a MKDIR from C:\temp as the current directory.

As a consequence the statement

move C:\temp C:\%folder%

that *renames* C:\temp does fail.

So, please, review your code and clarify.


Report Offensive Follow Up For Removal

Response Number 2
Name: smartguy2020
Date: May 9, 2008 at 12:45:03 Pacific
Subject: Deleting a created file
Reply: (edit)
Your right! It is a subfolder within C:\temp that I am creating. The batch file is set as a schedule task to create a folder with the name of today's date yyyymmdd. I have another program that accesses that folder once a day. I could go in and manually delete the folder everyday, but I have this spread out over 20+ computers and it is time consuming to delete each one manually. Having someone else do it leads to human error. If I do not delete this folder or have someone else do it, then there will be more than one folder within C:\temp that is named a date. One might be yesterday's date, one today's date, and another two days ago. The program I have accessing the folder gets confused and will access the folder it originally accessed unless it is has been deleted. Only then will it access the current and (hopefully) only folder in the C:\temp named the current date. I will test the last line that you say fails and if it is unneccesary, I will remove it. I hope I have explained in better detail what I am trying to accomplish. I just need to delete the folder that is being created daily after the program accesses that folder, so a new one can generate the next day and start the cycle over again. I cannot seem to figure this out. Thank you for your response!

Report Offensive Follow Up For Removal

Response Number 3
Name: IVO
Date: May 9, 2008 at 14:01:30 Pacific
Subject: Deleting a created file
Reply: (edit)
The following batch removes the previously created daily folder before instancing the new one

@echo off
cd C:\temp
set folder=%date:~10,4%%date:~7,2%%date:~4,2%
for /F %%j in ('dir /AD /B 20*') do RD %%j /Q /S
mkdir %folder%

Beware that works till year 2099 only!


Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: May 10, 2008 at 00:55:16 Pacific
Subject: Deleting a created file
Reply: (edit)
Or, add this line to your bat. It creates DELOLD.BAT which you can run or schedule whenever.

> delold.bat echo rd /s /q c:\temp\%folder%


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Deleting a created file

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software



Version Tracker Pro
Keep your software current and secure, effortlessly

Click Here for a Free Scan

Driver Agent
Automatically find the latest drivers for your computer.
Click Here for a Free Scan



The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC