Flux rss
Search : in
By : Relevance Date Username
Statut :

Batch File To delete folders

ituserit, on Friday 2 May 2008 à 12:45:32
Hello,


I hava folder that i want to periodically clean out old folders. for example a folder is created every day that looks like 20080304. I want to Keep the last 30 folders and delete any folder dated before that. I am just getting started using the SET and FOR commands and need a little help getting this one going.

Thank in advance,
Configuration: Windows XP
Internet Explorer 6.0
Reply to ituserit  Report this message to moderators Go to last message

2


  • This message seems useful, vote!
  • Report this message to moderators
yashmaur, on Friday 2 May 2008 à 15:09:01
Hai


Try This .. It Will Skip The Latest 30 Folders And Delete The Rest .. It Is In Debug Mode ... Remove The Echo from line 5 after "do" to actually make it delete the folders



:: --- BATCH SCRIPT START ---
@echo off
setlocal
set source=C:\source
pushd "%source%"
for /f "skip=30 delims=" %%a in ('dir /b /a:d /o:-d 2^>NUL') do echo rmdir /s /q "%%a"
popd
endlocal
:: --- BATCH SCRIPT END ---
Reply to yashmaur

6


  • This message seems useful, vote!
  • Report this message to moderators
cyribis, on Tuesday 22 July 2008 à 18:35:22
Hai,

I wanted to use your batchfile that would skip over the last 30 folders created in a parent folder--and delete the ones older than that. But I'm having difficulty in doing so. Allow me to elaborate a bit on what situation I'm facing. On our SAN, we have a folder that our backup-to-disk files go to. I'm using Symantec Backup Exec--and I'm backing up a Sharepoint server, so it creates these IMG folders every day due to the GRT feature. Moving right along, I want to write a batch file that will delete the IMG folders older than say...8 days.
I tried to alter the batch file you created here to suit my needs, but it didn't work. Any help you or others could provide would be greatly appreciate! Thanks in advance!
Reply to cyribis

9


  • This message seems useful, vote!
  • Report this message to moderators
Achi, on Thursday 4 September 2008 à 03:10:57
Can you able to teach me or explain step by step the batch file that you created to delete folders?
Reply to Achi

11


  • This message seems useful, vote!
  • Report this message to moderators
troyw, on Monday 22 September 2008 à 16:14:54
I used you batch file and it worked very well.
I just wanted to thank you.

Thanks,
troyw
Reply to troyw

13


  • This message seems useful, vote!
  • Report this message to moderators
Mainak Ghosh, on Thursday 25 September 2008 à 12:24:05
Hi

Can you help in deleting just the latest folder from a set of folders?
Thanks in advance.
Reply to Mainak Ghosh

3


  • 1
    This message seems useful, vote!
  • Ce message ne vous semble pas utile, votez !
  • Report this message to moderators
percy8, on Friday 2 May 2008 à 16:55:35
wow thats awesome never thought that we can do such things
Reply to percy8

4


  • This message seems useful, vote!
  • Report this message to moderators
rekj316, on Wednesday 28 May 2008 à 15:30:40
I am trying to create a batch file that will clean a mapped drive out nightly at a set time. I will attach the batch file to scheduled tasks on the Server to clean out the folder the drive is mapped to. Here is the basic set up

C:\Test (folder the drive will be mapped to)

net use \\serverxx\Test (the mapped drive to the Test folder)

My clients will save their files to their local L:\ that is mapped to c:\Test. The c:\Test needs to be cleaned out at 11:00 nightly. Any help will be appreciated.
Reply to rekj316

5


  • This message seems useful, vote!
  • Report this message to moderators
ram, on Tuesday 17 June 2008 à 07:12:46
dear sir
not useful this bach file
i need a file thah working autometic copy file & hdd ful then delete autometic
Reply to ram

7


  • This message seems useful, vote!
  • Report this message to moderators
varaprasad, on Monday 4 August 2008 à 21:53:49
Thank you verymuch. I will use this to delete the files older than 30days.
Reply to varaprasad

8


  • This message seems useful, vote!
  • Report this message to moderators
Maria, on Friday 22 August 2008 à 15:45:36
Hi,

Can I please have a copy of the batch file that worked for you.
I am trying to delete my backup files from my :\backup folder that is timestemped 2 days older than todays date.
I have no luck so far..
Thank you!
Maria
Reply to Maria

10


  • This message seems useful, vote!
  • Report this message to moderators
ITMan, on Saturday 6 September 2008 à 03:20:29
U might want to download a freeware Backup software called Comodo.

It backup the files in sub-folders and after making a backup of the file, it will delete it.

But be advice, the software will not delete the folders.

bye.
Reply to ITMan

12


  • This message seems useful, vote!
  • Report this message to moderators
TechnoThoughts, on Tuesday 23 September 2008 à 04:58:23
Hai,

Thanks for posting the delete folder batch file it helped me a lot tonight.
Reply to TechnoThoughts

14


  • This message seems useful, vote!
  • Report this message to moderators
javilan, on Thursday 16 October 2008 à 16:45:09
Thank you for this, worked like a charm
Reply to javilan

15


  • This message seems useful, vote!
  • Report this message to moderators
Maria, on Friday 17 October 2008 à 15:05:22
Hi,

I am still looking for a code (possibly DOS batch file) that will delete all of the older files in the c:\bkp folder
and only keep the latest backup files that was named and timestamped by another batch file as 10172008_abc.bkp
as an example.
All of the backup files gets moved into this one folder from all of the servers.
I could move first the 2 days old files to another folder that I could create, but even than I would have to delete them from that second backup folder adventually.
Can you please email me the full code?

Thank you!

Maria
Reply to Maria


  • This message seems useful, vote!
  • Report this message to moderators
Coddy, on Saturday 8 November 2008 à 22:32:16
Cool thanks I optimized it so when I clicked it it deletes what folders contents 1-7
or alows me to move it from one to the other.
Reply to Coddy

16


  • This message seems useful, vote!
  • Report this message to moderators
Online_ToughGuy, on Friday 21 November 2008 à 15:18:16
Guys, It is not working for me see below but I dont get any errors???? Any Ideas?
ECHO is on.

C:\Cameras>setlocal

C:\Cameras>set source=C:\cameras\cam01

C:\Cameras>pushd "C:\cameras\cam01"

C:\Cameras\cam01>for /F "skip=5 delims=" %a in ('dir /b /a:d /o:-d 2>NUL') do ec
ho rmdir /s /q "%a"

C:\Cameras\cam01>echo rmdir /s /q "1116"
rmdir /s /q "1116"

C:\Cameras\cam01>echo rmdir /s /q "1115"
rmdir /s /q "1115"

C:\Cameras\cam01>echo rmdir /s /q "1114"
rmdir /s /q "1114"

C:\Cameras\cam01>echo rmdir /s /q "1113"
rmdir /s /q "1113"

C:\Cameras\cam01>echo rmdir /s /q "1112"
rmdir /s /q "1112"

C:\Cameras\cam01>echo rmdir /s /q "1111"
rmdir /s /q "1111"

C:\Cameras\cam01>echo rmdir /s /q "1110"
rmdir /s /q "1110"

C:\Cameras\cam01>echo rmdir /s /q "1109"
rmdir /s /q "1109"

C:\Cameras\cam01>pause
Press any key to continue . . .
Reply to Online_ToughGuy

17


  • This message seems useful, vote!
  • Report this message to moderators
 Online_ToughGuy, on Friday 21 November 2008 à 16:12:29
ECHO is on.

C:\Cameras>setlocal

C:\Cameras>set source=C:\cameras\cam01

C:\Cameras>pushd "C:\cameras\cam01"

C:\Cameras\cam01>for /F "skip=5 delims=" %a in ('dir /b /a:d /o:-d 2>NUL') do ec
ho rmdir /s /q "%a"

C:\Cameras\cam01>echo rmdir /s /q "1116"
rmdir /s /q "1116"

C:\Cameras\cam01>echo rmdir /s /q "1115"
rmdir /s /q "1115"

C:\Cameras\cam01>echo rmdir /s /q "1114"
rmdir /s /q "1114"

C:\Cameras\cam01>echo rmdir /s /q "1113"
rmdir /s /q "1113"

C:\Cameras\cam01>echo rmdir /s /q "1112"
rmdir /s /q "1112"

C:\Cameras\cam01>echo rmdir /s /q "1111"
rmdir /s /q "1111"

C:\Cameras\cam01>echo rmdir /s /q "1110"
rmdir /s /q "1110"

C:\Cameras\cam01>echo rmdir /s /q "1109"
rmdir /s /q "1109"

C:\Cameras\cam01>pause
Press any key to continue . . .

forgot to add me email address
Reply to Online_ToughGuy

Résultats pour Batch File To delete folders

Error Deleting File or Folder Hello, I have a mysterious folder on my desktop that I want to delete but I keep getting, "Error Deleting File or Folder. Cannot remove folder: The directory is not empty." Inside the folder is another folder, and inside that one is another folder,... en.kioskea.net/forum/affich-11059-error-deleting-file-or-folder
Batch file for deleteing specific lines Hello, would anyone know how i would create a batch file to find a line in a file and delete all of the lines under that line? thanks en.kioskea.net/forum/affich-25149-batch-file-for-deleteing-specific-lines
Help with Loop in batch File using input from (Solved) Hi Together I try to scan some PCs remotely and do want to automize this task. I created a batch file doing a good job, however, it scans only one pc and then I do need to change the target system name. I now want to create a comma seperated list,... en.kioskea.net/forum/affich-15768-help-with-loop-in-batch-file-using-input-from

Résultats pour Batch File To delete folders

How to Password Protect your Files and FoldersHow to Password Protect your Files and Folders How to password protect a Word document Password protection on Windows 3.x, Windows 95 and Windows 98 Password protection on Windows XP Password protection on Windows XP Home Edition Password... en.kioskea.net/faq/sujet-270-how-to-password-protect-your-files-and-folders
What to do if a file cannot be deletedWhat to do if a file cannot be deleted How to get rid of the file? Solution 1: Ensure that the file/folder is not in use Solution 2: Run your system on Safe Mode Solution 3: Download or update your Antivirus program Solution 4: Use... en.kioskea.net/faq/sujet-292-what-to-do-if-a-file-cannot-be-deleted

Résultats pour Batch File To delete folders

Batch file name(s) in memory? os XpHello, How would I go about writing a batch file to copy all the file names in a folder...just the file names not the files and then rename them to something standard like "video1.avi", "video2.avi",etc. THEN when I'm ready rename them to the... en.kioskea.net/forum/affich-1618-batch-file-name-s-in-memory-os-xp
Batch filesDear All i have an application and i want to make the batch file so that when i run the file automaically i will copy all the files into another folder So Experts tell me how can i do that ! Thanks Pranav en.kioskea.net/forum/affich-17526-batch-files
DOS commands in a batch fileHello, I'm after a batch file that will press a button. I have used " rundll32.exe shell32.dll, Control_RunDLL inetcpl.cpl" to successfully display/access Internet Options. Now how to select the General tab ? [ set the focus to General Tab ?] and... en.kioskea.net/forum/affich-4105-dos-commands-in-a-batch-file

Résultats pour Batch File To delete folders

Download Easy File LockerTo keep your privacy and secure up your data on your machine, the best way is to hide them altogether. Easy File Locker is primarily a tool to block access, modification, reading, deleting, moving or copying your files or folders. But to make... en.kioskea.net/telecharger/telecharger-1082-easy-file-locker
Download Disk DefragFragmentation is caused by creating and deleting files and folders, installing new software, and downloading files from the Internet. Computers do not necessarily save an entire file or folder in a single space on a disk; they're saved in the first... en.kioskea.net/telecharger/telecharger-90-disk-defrag

Résultats pour Batch File To delete folders

>Operating Systems - Windows - Tips and Tricks - Organising Files and Folders You can add shortcuts to files or folders in the Start menu by going to "Start/Settings/Taskbar and Start Menu/Advanced" (or by going to "c:\windows\start"). Windows 98 even lets you drag a program to the Start menu and place it wherever you want,... en.kioskea.net/win/winastor.php3