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!
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.
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!
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