delete 2 days older folders

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Vikky_Vik
Posts: 7
Joined: 27 Dec 2011 03:26

Re: delete 2 days older folders

#16 Post by Vikky_Vik » 28 Dec 2011 06:24

Hi aGerman,

Thanks a lot for your help.
Your script is working absolutely fine for me.
I really appreciate your help.

Best Regards,
Vikky_Vik

-----------------

Hi squashman,

Thanks a lot for your help also. I really appreciate your help also.

Best Regards,
Vikky_Vik

mokomoji
Posts: 1
Joined: 04 Jan 2012 06:05

Re: delete 2 days older folders

#17 Post by mokomoji » 04 Jan 2012 06:24

1. http://blog.naver.com/mokomoji/130117861406 - D-daY 100% calculation

2. http://blog.naver.com/mokomoji/130029578178 - week
Mon Tue Wed Thu Fri Sat Sun
file make day - to 2 week day
today monday - 2day = satday
max day 6day delete

3. windows server type command

2 line command end

@echo off
FORFILES /D -2 /m filesname

exsemple

forfiles /P D:\backup\WEB_SOURCE\2010\ /D -7 /C "cmd /c del D:\backup\WEB_SOURCE\2010\@file"

forfiles /P D:\backup\WEB_SOURCE\2010\ /D -7 /C "cmd /c rmdir /s /q D:\backup\WEB_SOURCE\2010\@file"

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: delete 2 days older folders

#18 Post by Squashman » 04 Jan 2012 06:36

mokomoji wrote:1. http://blog.naver.com/mokomoji/130117861406 - D-daY 100% calculation

2. http://blog.naver.com/mokomoji/130029578178 - week
Mon Tue Wed Thu Fri Sat Sun
file make day - to 2 week day
today monday - 2day = satday
max day 6day delete

3. windows server type command

2 line command end

@echo off
FORFILES /D -2 /m filesname

exsemple

forfiles /P D:\backup\WEB_SOURCE\2010\ /D -7 /C "cmd /c del D:\backup\WEB_SOURCE\2010\@file"

forfiles /P D:\backup\WEB_SOURCE\2010\ /D -7 /C "cmd /c rmdir /s /q D:\backup\WEB_SOURCE\2010\@file"

While I did mention FORFILES in my 1st post the user did not reply to whether they had FORFILES on all their computers. It is not native to XP but technically can be installed on XP.

Your solution also does not take into account the pattern matching for the beginning of the file name. Don't think the /M switch can take a regular expression. It needs to account for multiple days.

Forfiles is one of my favorite utilities though for deleting files older than so many days.

deadfraggle
Posts: 1
Joined: 10 Jan 2012 17:35

Re: delete 2 days older folders

#19 Post by deadfraggle » 10 Jan 2012 17:41

Don't mean to hijack this thread, but I want to do something similar. I want to copy all of the files created yesterday in 'folder A' to 'folder B'. I look at the code presented here and my head swims. Anyone know the command(s) to do this?

Post Reply