1.    23 Aug 2007 #1
    Brandon Shell Guest

    Re: directory and file date


    Try this. I assumed you meant last changed.
    get-childitem e: -recurse | where{$_.LastWriteTime -lt
    (([datetime]::now).Addmonths(-3))}


    "frank" <frank@discussions.microsoft.com> wrote in message
    news:48C96B5F-970B-428F-883C-02D7DAFB8178@microsoft.com...
    >I was wondering if any has a script that will check an e: drive directory
    >and
    > subdirctory but only listthe directory and files that are older then 3
    > months
    >
    >
    > thanks
    >
    >
    >
    > frank


      My System SpecsSystem Spec

  2.    23 Aug 2007 #2
    frank Guest

    directory and file date


    I was wondering if any has a script that will check an e: drive directory and
    subdirctory but only listthe directory and files that are older then 3 months


    thanks



    frank
      My System SpecsSystem Spec

  3.    23 Aug 2007 #3
    ebgreen Guest

    RE: directory and file date


    Here is a quick one-liner that will hopefully point you in the right
    direction. It should list all the files and folders that were accessed more
    than 45 days ago:

    ls | ?{((get-date).Subtract($_.LastWriteTime).Days -gt 45)}

    "frank" wrote:

    > I was wondering if any has a script that will check an e: drive directory and
    > subdirctory but only listthe directory and files that are older then 3 months
    >
    >
    > thanks
    >
    >
    >
    > frank

      My System SpecsSystem Spec

  4.    23 Aug 2007 #4
    Brandon Shell Guest

    Re: directory and file date


    Sup Ebgreen... just some helpful hints.

    - When posting stuff for other people I try to avoid alias (I know, I
    know... it is super hard)

    - Not sure you know, but system.datetime has a few methods you can add
    negative numbers to that are quite useful
    AddDays
    AddHours
    AddMilliseconds
    AddMinutes
    AddMonths
    AddSeconds
    AddTicks
    AddYears

    - For access time I would use .LastAccessTime instead LastWriteTime

    "ebgreen" <ebgreen@discussions.microsoft.com> wrote in message
    news:F6E82F07-5945-4770-85E6-2792466373C3@microsoft.com...
    > Here is a quick one-liner that will hopefully point you in the right
    > direction. It should list all the files and folders that were accessed
    > more
    > than 45 days ago:
    >
    > ls | ?{((get-date).Subtract($_.LastWriteTime).Days -gt 45)}
    >
    > "frank" wrote:
    >
    >> I was wondering if any has a script that will check an e: drive directory
    >> and
    >> subdirctory but only listthe directory and files that are older then 3
    >> months
    >>
    >>
    >> thanks
    >>
    >>
    >>
    >> frank


      My System SpecsSystem Spec

  5.    23 Aug 2007 #5
    ebgreen Guest

    Re: directory and file date


    All very valid points. I have mixed feelings regarding aliases. On the one
    hand I generally avoid then in script files. I think they would make
    maintenance difficult since there is no guarantee that they will always
    exist. At the command line I use them extensively. As for posting in threads,
    I think that while it could be confusing to someone who doesn't know them,
    how else will they learn about them? I didn't know ? = Where-Object until I
    saw it in a blog post one time. Generally I do avoid them in posts. What I
    will do is work out the answer at the command line using aliases then post
    the line without the alias. (Hey, that would be a nice function. You hand it
    a string and it gives the string back with all the aliases replaced by the
    actual command.) In this case I was just being lazy and did a copy and paste.
    Also, not to be pedantic, but you used an alias as well (where).

    As for .LastAccessTime vs. .LastWriteTime I suppose it would depend on the
    original poster's need. When I look at archive scripts I usually don't care
    how long it has been since someone looked at the file, I just care about the
    last time that someone made a change to the file. Although the other view is
    just as (and perhaps more) valid.

    So here is my suggestion with the proposed changes:

    get-childitem | where-object{((get-date).Subtract($_.LastAccessTime).Days
    -gt 45)}


    "Brandon Shell" wrote:

    > Sup Ebgreen... just some helpful hints.
    >
    > - When posting stuff for other people I try to avoid alias (I know, I
    > know... it is super hard)
    >
    > - Not sure you know, but system.datetime has a few methods you can add
    > negative numbers to that are quite useful
    > AddDays
    > AddHours
    > AddMilliseconds
    > AddMinutes
    > AddMonths
    > AddSeconds
    > AddTicks
    > AddYears
    >
    > - For access time I would use .LastAccessTime instead LastWriteTime
    >
    > "ebgreen" <ebgreen@discussions.microsoft.com> wrote in message
    > news:F6E82F07-5945-4770-85E6-2792466373C3@microsoft.com...
    > > Here is a quick one-liner that will hopefully point you in the right
    > > direction. It should list all the files and folders that were accessed
    > > more
    > > than 45 days ago:
    > >
    > > ls | ?{((get-date).Subtract($_.LastWriteTime).Days -gt 45)}
    > >
    > > "frank" wrote:
    > >
    > >> I was wondering if any has a script that will check an e: drive directory
    > >> and
    > >> subdirctory but only listthe directory and files that are older then 3
    > >> months
    > >>
    > >>
    > >> thanks
    > >>
    > >>
    > >>
    > >> frank

    >
    >

      My System SpecsSystem Spec

  6.    23 Aug 2007 #6
    Brandon Shell Guest

    Re: directory and file date


    Are you writting this one

    "Hey, that would be a nice function. You hand it
    a string and it gives the string back with all the aliases replaced by the
    actual command.) In this case I was just being lazy and did a copy and
    paste.
    Also, not to be pedantic, but you used an alias as well (where). "


    "ebgreen" <ebgreen@discussions.microsoft.com> wrote in message
    news:2A87B130-D20D-4A85-A35A-118BE06EF235@microsoft.com...
    > All very valid points. I have mixed feelings regarding aliases. On the one
    > hand I generally avoid then in script files. I think they would make
    > maintenance difficult since there is no guarantee that they will always
    > exist. At the command line I use them extensively. As for posting in
    > threads,
    > I think that while it could be confusing to someone who doesn't know them,
    > how else will they learn about them? I didn't know ? = Where-Object until
    > I
    > saw it in a blog post one time. Generally I do avoid them in posts. What I
    > will do is work out the answer at the command line using aliases then post
    > the line without the alias. (Hey, that would be a nice function. You hand
    > it
    > a string and it gives the string back with all the aliases replaced by the
    > actual command.) In this case I was just being lazy and did a copy and
    > paste.
    > Also, not to be pedantic, but you used an alias as well (where).
    >
    > As for .LastAccessTime vs. .LastWriteTime I suppose it would depend on the
    > original poster's need. When I look at archive scripts I usually don't
    > care
    > how long it has been since someone looked at the file, I just care about
    > the
    > last time that someone made a change to the file. Although the other view
    > is
    > just as (and perhaps more) valid.
    >
    > So here is my suggestion with the proposed changes:
    >
    > get-childitem | where-object{((get-date).Subtract($_.LastAccessTime).Days
    > -gt 45)}
    >
    >
    > "Brandon Shell" wrote:
    >
    >> Sup Ebgreen... just some helpful hints.
    >>
    >> - When posting stuff for other people I try to avoid alias (I know, I
    >> know... it is super hard)
    >>
    >> - Not sure you know, but system.datetime has a few methods you can add
    >> negative numbers to that are quite useful
    >> AddDays
    >> AddHours
    >> AddMilliseconds
    >> AddMinutes
    >> AddMonths
    >> AddSeconds
    >> AddTicks
    >> AddYears
    >>
    >> - For access time I would use .LastAccessTime instead LastWriteTime
    >>
    >> "ebgreen" <ebgreen@discussions.microsoft.com> wrote in message
    >> news:F6E82F07-5945-4770-85E6-2792466373C3@microsoft.com...
    >> > Here is a quick one-liner that will hopefully point you in the right
    >> > direction. It should list all the files and folders that were accessed
    >> > more
    >> > than 45 days ago:
    >> >
    >> > ls | ?{((get-date).Subtract($_.LastWriteTime).Days -gt 45)}
    >> >
    >> > "frank" wrote:
    >> >
    >> >> I was wondering if any has a script that will check an e: drive
    >> >> directory
    >> >> and
    >> >> subdirctory but only listthe directory and files that are older then 3
    >> >> months
    >> >>
    >> >>
    >> >> thanks
    >> >>
    >> >>
    >> >>
    >> >> frank

    >>
    >>


      My System SpecsSystem Spec

  7.    23 Aug 2007 #7
    Shay Levi Guest

    Re: directory and file date


    >> Hey, that would be a nice function...
    I think it exists in PrimalScript 2007

    As for writing posts with aliases, you can always add a comment like

    # ? = where-object
    # % = foreach-object
    dir . | % {some code}


    Shay
    http://scriptolog.blogspot.com



    > All very valid points. I have mixed feelings regarding aliases. On the
    > one hand I generally avoid then in script files. I think they would
    > make maintenance difficult since there is no guarantee that they will
    > always exist. At the command line I use them extensively. As for
    > posting in threads, I think that while it could be confusing to
    > someone who doesn't know them, how else will they learn about them? I
    > didn't know ? = Where-Object until I saw it in a blog post one time.
    > Generally I do avoid them in posts. What I will do is work out the
    > answer at the command line using aliases then post the line without
    > the alias. (Hey, that would be a nice function. You hand it a string
    > and it gives the string back with all the aliases replaced by the
    > actual command.) In this case I was just being lazy and did a copy and
    > paste. Also, not to be pedantic, but you used an alias as well
    > (where).
    >
    > As for .LastAccessTime vs. .LastWriteTime I suppose it would depend on
    > the original poster's need. When I look at archive scripts I usually
    > don't care how long it has been since someone looked at the file, I
    > just care about the last time that someone made a change to the file.
    > Although the other view is just as (and perhaps more) valid.
    >
    > So here is my suggestion with the proposed changes:
    >
    > get-childitem |
    > where-object{((get-date).Subtract($_.LastAccessTime).Days -gt 45)}
    >
    > "Brandon Shell" wrote:
    >
    >> Sup Ebgreen... just some helpful hints.
    >>
    >> - When posting stuff for other people I try to avoid alias (I know, I
    >> know... it is super hard)
    >>
    >> - Not sure you know, but system.datetime has a few methods you can
    >> add
    >> negative numbers to that are quite useful
    >> AddDays
    >> AddHours
    >> AddMilliseconds
    >> AddMinutes
    >> AddMonths
    >> AddSeconds
    >> AddTicks
    >> AddYears
    >> - For access time I would use .LastAccessTime instead LastWriteTime
    >>
    >> "ebgreen" <ebgreen@discussions.microsoft.com> wrote in message
    >> news:F6E82F07-5945-4770-85E6-2792466373C3@microsoft.com...
    >>
    >>> Here is a quick one-liner that will hopefully point you in the right
    >>> direction. It should list all the files and folders that were
    >>> accessed
    >>> more
    >>> than 45 days ago:
    >>> ls | ?{((get-date).Subtract($_.LastWriteTime).Days -gt 45)}
    >>>
    >>> "frank" wrote:
    >>>
    >>>> I was wondering if any has a script that will check an e: drive
    >>>> directory
    >>>> and
    >>>> subdirctory but only listthe directory and files that are older
    >>>> then 3
    >>>> months
    >>>> thanks
    >>>>
    >>>> frank
    >>>>



      My System SpecsSystem Spec

  8.    23 Aug 2007 #8
    ebgreen Guest

    Re: directory and file date


    I've given it some thought and for the time being, no. It would actually
    have to be a fairly complex recursive descent parser and I don't have that
    much free time.

    "Shay Levi" wrote:

    > >> Hey, that would be a nice function...

    > I think it exists in PrimalScript 2007
    >
    > As for writing posts with aliases, you can always add a comment like
    >
    > # ? = where-object
    > # % = foreach-object
    > dir . | % {some code}
    >
    >
    > Shay
    > http://scriptolog.blogspot.com
    >
    >
    >
    > > All very valid points. I have mixed feelings regarding aliases. On the
    > > one hand I generally avoid then in script files. I think they would
    > > make maintenance difficult since there is no guarantee that they will
    > > always exist. At the command line I use them extensively. As for
    > > posting in threads, I think that while it could be confusing to
    > > someone who doesn't know them, how else will they learn about them? I
    > > didn't know ? = Where-Object until I saw it in a blog post one time.
    > > Generally I do avoid them in posts. What I will do is work out the
    > > answer at the command line using aliases then post the line without
    > > the alias. (Hey, that would be a nice function. You hand it a string
    > > and it gives the string back with all the aliases replaced by the
    > > actual command.) In this case I was just being lazy and did a copy and
    > > paste. Also, not to be pedantic, but you used an alias as well
    > > (where).
    > >
    > > As for .LastAccessTime vs. .LastWriteTime I suppose it would depend on
    > > the original poster's need. When I look at archive scripts I usually
    > > don't care how long it has been since someone looked at the file, I
    > > just care about the last time that someone made a change to the file.
    > > Although the other view is just as (and perhaps more) valid.
    > >
    > > So here is my suggestion with the proposed changes:
    > >
    > > get-childitem |
    > > where-object{((get-date).Subtract($_.LastAccessTime).Days -gt 45)}
    > >
    > > "Brandon Shell" wrote:
    > >
    > >> Sup Ebgreen... just some helpful hints.
    > >>
    > >> - When posting stuff for other people I try to avoid alias (I know, I
    > >> know... it is super hard)
    > >>
    > >> - Not sure you know, but system.datetime has a few methods you can
    > >> add
    > >> negative numbers to that are quite useful
    > >> AddDays
    > >> AddHours
    > >> AddMilliseconds
    > >> AddMinutes
    > >> AddMonths
    > >> AddSeconds
    > >> AddTicks
    > >> AddYears
    > >> - For access time I would use .LastAccessTime instead LastWriteTime
    > >>
    > >> "ebgreen" <ebgreen@discussions.microsoft.com> wrote in message
    > >> news:F6E82F07-5945-4770-85E6-2792466373C3@microsoft.com...
    > >>
    > >>> Here is a quick one-liner that will hopefully point you in the right
    > >>> direction. It should list all the files and folders that were
    > >>> accessed
    > >>> more
    > >>> than 45 days ago:
    > >>> ls | ?{((get-date).Subtract($_.LastWriteTime).Days -gt 45)}
    > >>>
    > >>> "frank" wrote:
    > >>>
    > >>>> I was wondering if any has a script that will check an e: drive
    > >>>> directory
    > >>>> and
    > >>>> subdirctory but only listthe directory and files that are older
    > >>>> then 3
    > >>>> months
    > >>>> thanks
    > >>>>
    > >>>> frank
    > >>>>

    >
    >
    >

      My System SpecsSystem Spec

  9.    23 Aug 2007 #9
    ebgreen Guest

    Re: directory and file date


    Ooops...replied to the wrong post. My post immediately above should be here.

    "Brandon Shell" wrote:

    > Are you writting this one
    >
    > "Hey, that would be a nice function. You hand it
    > a string and it gives the string back with all the aliases replaced by the
    > actual command.) In this case I was just being lazy and did a copy and
    > paste.
    > Also, not to be pedantic, but you used an alias as well (where). "
    >
    >
    > "ebgreen" <ebgreen@discussions.microsoft.com> wrote in message
    > news:2A87B130-D20D-4A85-A35A-118BE06EF235@microsoft.com...
    > > All very valid points. I have mixed feelings regarding aliases. On the one
    > > hand I generally avoid then in script files. I think they would make
    > > maintenance difficult since there is no guarantee that they will always
    > > exist. At the command line I use them extensively. As for posting in
    > > threads,
    > > I think that while it could be confusing to someone who doesn't know them,
    > > how else will they learn about them? I didn't know ? = Where-Object until
    > > I
    > > saw it in a blog post one time. Generally I do avoid them in posts. What I
    > > will do is work out the answer at the command line using aliases then post
    > > the line without the alias. (Hey, that would be a nice function. You hand
    > > it
    > > a string and it gives the string back with all the aliases replaced by the
    > > actual command.) In this case I was just being lazy and did a copy and
    > > paste.
    > > Also, not to be pedantic, but you used an alias as well (where).
    > >
    > > As for .LastAccessTime vs. .LastWriteTime I suppose it would depend on the
    > > original poster's need. When I look at archive scripts I usually don't
    > > care
    > > how long it has been since someone looked at the file, I just care about
    > > the
    > > last time that someone made a change to the file. Although the other view
    > > is
    > > just as (and perhaps more) valid.
    > >
    > > So here is my suggestion with the proposed changes:
    > >
    > > get-childitem | where-object{((get-date).Subtract($_.LastAccessTime).Days
    > > -gt 45)}
    > >
    > >
    > > "Brandon Shell" wrote:
    > >
    > >> Sup Ebgreen... just some helpful hints.
    > >>
    > >> - When posting stuff for other people I try to avoid alias (I know, I
    > >> know... it is super hard)
    > >>
    > >> - Not sure you know, but system.datetime has a few methods you can add
    > >> negative numbers to that are quite useful
    > >> AddDays
    > >> AddHours
    > >> AddMilliseconds
    > >> AddMinutes
    > >> AddMonths
    > >> AddSeconds
    > >> AddTicks
    > >> AddYears
    > >>
    > >> - For access time I would use .LastAccessTime instead LastWriteTime
    > >>
    > >> "ebgreen" <ebgreen@discussions.microsoft.com> wrote in message
    > >> news:F6E82F07-5945-4770-85E6-2792466373C3@microsoft.com...
    > >> > Here is a quick one-liner that will hopefully point you in the right
    > >> > direction. It should list all the files and folders that were accessed
    > >> > more
    > >> > than 45 days ago:
    > >> >
    > >> > ls | ?{((get-date).Subtract($_.LastWriteTime).Days -gt 45)}
    > >> >
    > >> > "frank" wrote:
    > >> >
    > >> >> I was wondering if any has a script that will check an e: drive
    > >> >> directory
    > >> >> and
    > >> >> subdirctory but only listthe directory and files that are older then 3
    > >> >> months
    > >> >>
    > >> >>
    > >> >> thanks
    > >> >>
    > >> >>
    > >> >>
    > >> >> frank
    > >>
    > >>

    >
    >

      My System SpecsSystem Spec

  10.    23 Aug 2007 #10
    RichS Guest

    Re: directory and file date


    I did started something like that a few weeks back. See

    http://richardsiddaway.spaces.live.c...3E96!543.entry

    --
    Richard Siddaway
    Please note that all scripts are supplied "as is" and with no warranty
    Blog: http://richardsiddaway.spaces.live.com/
    PowerShell User Group: http://www.get-psuguk.org.uk


    "ebgreen" wrote:

    > All very valid points. I have mixed feelings regarding aliases. On the one
    > hand I generally avoid then in script files. I think they would make
    > maintenance difficult since there is no guarantee that they will always
    > exist. At the command line I use them extensively. As for posting in threads,
    > I think that while it could be confusing to someone who doesn't know them,
    > how else will they learn about them? I didn't know ? = Where-Object until I
    > saw it in a blog post one time. Generally I do avoid them in posts. What I
    > will do is work out the answer at the command line using aliases then post
    > the line without the alias. (Hey, that would be a nice function. You hand it
    > a string and it gives the string back with all the aliases replaced by the
    > actual command.) In this case I was just being lazy and did a copy and paste.
    > Also, not to be pedantic, but you used an alias as well (where).
    >
    > As for .LastAccessTime vs. .LastWriteTime I suppose it would depend on the
    > original poster's need. When I look at archive scripts I usually don't care
    > how long it has been since someone looked at the file, I just care about the
    > last time that someone made a change to the file. Although the other view is
    > just as (and perhaps more) valid.
    >
    > So here is my suggestion with the proposed changes:
    >
    > get-childitem | where-object{((get-date).Subtract($_.LastAccessTime).Days
    > -gt 45)}
    >
    >
    > "Brandon Shell" wrote:
    >
    > > Sup Ebgreen... just some helpful hints.
    > >
    > > - When posting stuff for other people I try to avoid alias (I know, I
    > > know... it is super hard)
    > >
    > > - Not sure you know, but system.datetime has a few methods you can add
    > > negative numbers to that are quite useful
    > > AddDays
    > > AddHours
    > > AddMilliseconds
    > > AddMinutes
    > > AddMonths
    > > AddSeconds
    > > AddTicks
    > > AddYears
    > >
    > > - For access time I would use .LastAccessTime instead LastWriteTime
    > >
    > > "ebgreen" <ebgreen@discussions.microsoft.com> wrote in message
    > > news:F6E82F07-5945-4770-85E6-2792466373C3@microsoft.com...
    > > > Here is a quick one-liner that will hopefully point you in the right
    > > > direction. It should list all the files and folders that were accessed
    > > > more
    > > > than 45 days ago:
    > > >
    > > > ls | ?{((get-date).Subtract($_.LastWriteTime).Days -gt 45)}
    > > >
    > > > "frank" wrote:
    > > >
    > > >> I was wondering if any has a script that will check an e: drive directory
    > > >> and
    > > >> subdirctory but only listthe directory and files that are older then 3
    > > >> months
    > > >>
    > > >>
    > > >> thanks
    > > >>
    > > >>
    > > >>
    > > >> frank

    > >
    > >

      My System SpecsSystem Spec

Page 1 of 2 12 LastLast

Similar Threads
Thread Forum
Create Directory with date time stamp
Ok, I feel like an idiot for not figuring this out. How do I create a new directory with the current date time? This doesn't seem to work for me.....
PowerShell
Copy file from one directory to a new directory, using excelspreadsheet as reference for items to be copied
All- I have an excel spreadsheet containing 7509 rows (Products), and I have a directory containing 16,421 image files. The images are all...
VB Script
Directory creation with a today's date
First, I'm not a n00b, but I'm no expert either, so details are appreciated. That said, here are the details. First, Windows 2000, then Windows XP I...
PowerShell
How do I view file date in file open dialogs and Win Explorer
Right now the closest thing in details view is date picture taken - (since when did my PC become a camera?). I do alot of image file editing and...
Vista file management
Photo date taken vs. file date
How can I get Vista Media Center photo gallery to show the date when a photo was taken, now what I see is the date of the file. Vista cannot be so...
Vista music pictures video
Setting up a directory and moving a file into that directory from
I have some files provided me on a CD - I have been told to select two files from the CD and move to a Directory, which I have established and...
Vista General
Setting up a directory and moving a file into that directory from
I have some files provided me on a CD - I have been told to select two files from the CD and move to a Directory, which I have established and...
Vista General

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • PC Help Forum
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    Designer Media Ltd
    All times are GMT -5. The time now is 20:58.
    .