> I would like to delete only $NtUninstall directories from 2009.
> I am not sure how to do it.
This is a one time process that surely would not require a batch file to complete. I would simply open explorer, navigate to the folder in question, set it to detail view, then simply sort the list by date. From there it is easy enough to select the group of folders needing deleted.
-- Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
Andy wrote:
> On Monday, November 12, 2012 2:58:51 PM UTC-6, Todd Vargo wrote:
>> On 11/12/2012 3:13 PM, Andy wrote:
>> > I would like to delete only $NtUninstall directories from 2009.
>> > I am not sure how to do it.
>> This is a one time process that surely would not require a batch file to
>> complete. I would simply open explorer, navigate to the folder in
>> question, set it to detail view, then simply sort the list by date. From
>> there it is easy enough to select the group of folders needing deleted.
> It would not be a one time event.
> I am cleaning up my daughters computer and it's a mess. :-)
Unless your daughter has several computers laying around, or keeps her system's clock set to 2009 during updates, it's *definitely* a 1-time thing. Todd's method is *exactly* how I would do it.
-- Nothing spells "imminent trauma" like a group of bored teenage boys.
On Monday, November 12, 2012 10:56:03 PM UTC-6, Auric__ wrote:
> Andy wrote:
> > On Monday, November 12, 2012 2:58:51 PM UTC-6, Todd Vargo wrote:
> >> On 11/12/2012 3:13 PM, Andy wrote:
> >> > I would like to delete only $NtUninstall directories from 2009.
> >> > I am not sure how to do it.
> >> This is a one time process that surely would not require a batch file to
> >> complete. I would simply open explorer, navigate to the folder in
> >> question, set it to detail view, then simply sort the list by date. From
> >> there it is easy enough to select the group of folders needing deleted.
> > It would not be a one time event.
> > I am cleaning up my daughters computer and it's a mess. :-)
> Unless your daughter has several computers laying around, or keeps her
> system's clock set to 2009 during updates, it's *definitely* a 1-time thing.
> Todd's method is *exactly* how I would do it.
> --
> Nothing spells "imminent trauma" like a group of bored teenage boys.
I love learning and I think modifying this might work.
Take care,
Andy
@Echo Off
:: Code by OutCaste,
FOR /D /R c:\test %%X IN (now*.) DO RD /S /Q "%%X"
goto :EOF Set _TabSpace=
Setlocal EnableDelayedExpansion
:: User Variables
:: Set this to the number of days you want to keep
Set _DaysKept=800
:: Set this to the folder that contains the folders to check and delete
Set _Path=C:\Test1
:: Get todays date
Call :GetDate
Set _yy=%_fDate:~,4%
Set _mm=%_fDate:~4,2%
Set _dd=%_fDate:~6,2%
:: Convert todays date to Julian
Call :JDate %_yy% %_mm% %_dd%
Set _JToday=%_JDate%
:: Set delete date
Set /a _DelDate=_JToday-%_DaysKept%-1
:: Get time format, _iTime will be 0 if 12 hourt clock, 1 if 24 hour clock
:: Delims= is a TAB followed by a space in the next line
For /F "TOKENS=2* DELIMS=%_TabSpace%" %%A In ('REG QUERY "HKCU\Control Panel\International" /v iTime') Do Set _iTime=%%B
If Exist "%temp%\tf}1{" Del "%temp%\tf}1{"
PushD %_Path%
Set _s=s
If %_DaysKept%==1 set _s=
Echo Please wait, searching for folders more than %_DaysKept% day%_s% old
If %_iTime%==0 (Set _Tok=1,4*) Else (Set _Tok=1,3*)
For /F "tokens=%_Tok% skip=4" %%I In ('dir "%_Path%\1*" /AD /OD /TW ^|Findstr /E "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"') Do (
Set _Name=%%K
If "!_Name:~10!"=="" If %%J==^<DIR^> (
Call :GetDate %%I
Call :JDate !_fDate:~,4! !_fDate:~4,2! !_fDate:~6,2!
If !_JDate! LEQ %_DelDate% (
If Exist "%temp%\tf}1{" (
Echo %%I:%%~fK >>"%temp%\tf}1{"
) Else (
Echo.>"%temp%\tf}1{"
Echo Do you wish to delete the following folders?>>"%temp%\tf}1{"
Echo Date Name>>"%temp%\tf}1{"
Echo %%I:%%~fK >>"%temp%\tf}1{"
)) Else (
Goto :_allFound
)))
PopD
:_allFound
If Not Exist "%temp%\tf}1{" Echo No Folders Found to delete&Goto _Done
Type "%temp%\tf}1{" | More
Set _rdflag= /q
:_Prompt1
Set /P _resp=Delete All, None, or Prompt for each (A/N/P)?
If /I "%_resp:~0,1%"=="N" Goto _Done
If /I "%_resp:~0,1%"=="A" Goto _Removeold
If /I NOT "%_resp:~0,1%"=="P" (Echo (A/N/P only please)&Goto _Prompt1
Set _rdflag=
:_Removeold
For /F "tokens=1* skip=3 Delims=:" %%I In ('type "%temp%\tf}1{"') Do (
If "%_rdflag%"=="" Echo Deleting
rd /s%_rdflag% "%%J")
:_Done
If Exist "%temp%\tf}1{" Del "%temp%\tf}1{"
Goto:EOF
::===================================::
:: ::
:: - S u b r o u t i n e s - ::
:: ::
::===================================::
:JDate
:: Convert date to Julian
:: Arguments : YYYY MM DD
:: Returns : Julian date in variable _JDate
:: Usage
::Call :JDate %__GYear% %_GMonth% %_GDay%
:: First strip leading zeroes; a logical error in this
:: routine was corrected with help from Alexander Shapiro
::Code taken from datediff.bat written by Rob van der Woude
::http://www.robvanderwoude.com Set _JMM=%2
Set _JDD=%3
IF 1%_JMM% LSS 110 Set _JMM=%_JMM:~1%
IF 1%_JDD% LSS 110 Set _JDD=%_JDD:~1%
::
:: Algorithm based on Fliegel-Van Flandern
:: algorithm from the Astronomical Almanac,
:: provided by Doctor Fenton on the Math Forum
:: (http://mathforum.org/library/drmath/view/51907.html),
:: and converted to batch code by Ron Bakowski.
Set /A _JMonth1 = ( %_JMM% - 14 ) / 12
Set /A _JYear1 = %1 + 4800
Set /A _JDate = 1461 * ( %_JYear1% + %_JMonth1% ) / 4 + 367 * ( %_JMM% - 2 -12 * %_JMonth1% ) / 12 - ( 3 * ( ( %_JYear1% + %_JMonth1% + 100 ) / 100 ) ) / 4 + %_JDD% - 32075
For %%A In (_JMonth1 _JYear1) Do Set %%A=
Goto:EOF
:GetDate
:: This subroutine will always display the same results,
:: for the date independent of "International" settings.
:: This batch file uses REG.EXE from the NT Resource Kit
:: (already installed with WinXP and Vista)
:: to read the "International" settings from the registry.
:: Date is returned as yyyymmdd in variable _fdate
:: Modified from SortDate Written by Rob van der Woude
:: http://www.robvanderwoude.com ::
If NOT [%1]==[] Set Date=%1
If "%date%A" LSS "A" (Set _NumTok=1-3) Else (Set _NumTok=2-4)
:: Delims= is a TAB followed by a space in the next two lines
For /F "SKIP=3 TOKENS=2* DELIMS=%_TabSpace%" %%A In ('REG QUERY "HKCU\Control Panel\International" /v iDate') Do Set _iDate=%%B
For /F "SKIP=3 TOKENS=2* DELIMS=%_TabSpace%" %%A In ('REG QUERY "HKCU\Control Panel\International" /v sDate') Do Set _sDate=%%B
IF %_iDate%==0 For /F "TOKENS=%_NumTok% DELIMS=%_sDate% " %%B In ("%date%") Do Set _fdate=%%D%%B%%C
IF %_iDate%==1 For /F "TOKENS=%_NumTok% DELIMS=%_sDate% " %%B In ("%date%") Do Set _fdate=%%D%%C%%B
IF %_iDate%==2 For /F "TOKENS=%_NumTok% DELIMS=%_sDate% " %%B In ("%date%") Do Set _fdate=%%B%%C%%D
Goto:EOF
In alt.msdos.batch.nt message <f44c37a9-4520-4437-9910-ecac5cf6f738@goog
legroups.com>, Mon, 12 Nov 2012 12:13:54, Andy
<chocolatemint77...@yahoo.com> posted:
>I would like to delete only $NtUninstall directories from 2009.
>I am not sure how to do it.
That depends on what you mean by 2009.
HUNT, via sig line 3, in 16 & 32 bit systems, will do it using the "DOS"
datestamp. Frequently used for two decades.
SEEK / SEAKFYLE, via sig line 3 32-bit subdirectory, should be able to
do it in 32 or 64 bit systems using any of the three dates. Recent;
tested; little used.
CAVEAT for users with Summer Time at year rollover - apparent directory
dates might be an hour wrong (0.5 hour for LHI, if Microsoft knew of the
place).
In alt.msdos.batch.nt message <k821uu$gi...@news.albasani.net>, Thu, 15
Nov 2012 01:26:39, Todd Vargo <tlva...@sbcglobal.netz> posted:
>Also, I doubt any files from 2013 would be found on 15/11/2012.
In this international medium, ISO 8601 dates should be used. Since I
think you are American, that date must mean Day 11 of Month 15 of 2012,
which is 2013-03-15 ...
<http://www.merlyn.demon.co.uk/zipfiles/hunttest.zip> contains zero-
length files with various datestamps, ranging from 1980-00-00 00:00:00
to 2107-15-31 31:63:62 IIRC - but read those rated with reliable DOS
tools, not with lying GUI stuff. It includes a TXT file.
> In alt.msdos.batch.nt message <k821uu$gi...@news.albasani.net>, Thu, 15
> Nov 2012 01:26:39, Todd Vargo <tlva...@sbcglobal.netz> posted:
>> Also, I doubt any files from 2013 would be found on 15/11/2012.
> In this international medium, ISO 8601 dates should be used. Since I
> think you are American, that date must mean Day 11 of Month 15 of 2012,
> which is 2013-03-15 ...
Poor John, always playing the fool. Perhaps if you bother to examine the quoted lines at the top of my post (you know, the portion you snipped), you might realize I copied it from foxi's post in response to same.
> <http://www.merlyn.demon.co.uk/zipfiles/hunttest.zip> contains zero-
> length files with various datestamps, ranging from 1980-00-00 00:00:00
> to 2107-15-31 31:63:62 IIRC - but read those rated with reliable DOS
> tools, not with lying GUI stuff. It includes a TXT file.
More *irrelevant* drivel. Not related to this discussion.
Don't troll (tread) on me!
-- Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
>On 11/16/2012 2:50 PM, Dr J R Stockton wrote:
>> In alt.msdos.batch.nt message <k821uu$gi...@news.albasani.net>, Thu, 15
>> Nov 2012 01:26:39, Todd Vargo <tlva...@sbcglobal.netz> posted:
>>> Also, I doubt any files from 2013 would be found on 15/11/2012.
>> In this international medium, ISO 8601 dates should be used. Since I
>> think you are American, that date must mean Day 11 of Month 15 of 2012,
>> which is 2013-03-15 ...
>Poor John, always playing the fool. Perhaps if you bother to examine
>the quoted lines at the top of my post (you know, the portion you
>snipped), you might realize I copied it from foxi's post in response to
>same.
You are responsible for what you copy, unless indicated by standard
quoting methods or conspicuously otherwise. Reproducing an attribution
verbatim, with an extra quote character, is standard; extracting
substrings is not.
>> <http://www.merlyn.demon.co.uk/zipfiles/hunttest.zip> contains zero-
>> length files with various datestamps, ranging from 1980-00-00 00:00:00
>> to 2107-15-31 31:63:62 IIRC - but read those rated with reliable DOS
>> tools, not with lying GUI stuff. It includes a TXT file.
>More *irrelevant* drivel. Not related to this discussion.
>Don't troll (tread) on me!
Were US education better, you might have become a half-wit. You are
doubting whether future-dated files are liable to exist in a computer; I
give there a counter-example.
There is no need to allow for the strictly impossible; but true DOS file
datestamps can have any value, in even seconds, between those above,
inclusive.
-- (c) John Stockton, nr London, UK. E-mail, see Home Page. Turnpike v6.05.
Website <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.