close

Privacy guaranteed - Your email is not shared with anyone.

Welcome to Glock Talk

Why should YOU join our Glock forum?

  • Converse with other Glock Enthusiasts
  • Learn about the latest hunting products
  • Becoming a member is FREE and EASY

If you consider yourself a beginner or an avid shooter, the Glock Talk community is your place to discuss self defense, concealed carry, reloading, target shooting, and all things Glock.

I need a "file aging" utility

Discussion in 'Tech Talk' started by gwalchmai, Aug 1, 2005.

  1. gwalchmai

    gwalchmai Lucky Member

    24,129
    708
    Jan 9, 2002
    Outside the perimeter
    I have a directory on my network that we use for transfers between users. It's intended to be a very temporary file drop, but we have some folks who leave files on there forever, eventually filling it up.

    I need a utility that will take a snapshot of the directory every day and compare it to the previous day's snapshot, then remove any files or subdirectories which have been there longer than, say, a month. Of course, we can't use the datestamps on the files because they will show the date created, not the date put in the transfer directory.

    Before I start writing this I thought I'd check to see if the GT TT KB knew of anything like it (Windows, please).

    Thanks!
     
  2. prism

    prism more ammo

    1,420
    8
    Sep 26, 2002
    Indiana
    no idea.

    but, could you do something like take ownership of the files, or rename them (like adding a hyphen). this might generate a new timestamp.
     


  3. srhoades

    srhoades

    2,800
    10
    Jul 14, 2000
    Although I suck at them, what you need is a script. You can then schedule it to run once a day after everyone leaves.
     
  4. GTIMANiac

    GTIMANiac

    77
    0
    Jul 14, 2001
  5. HerrGlock

    HerrGlock Scouts Out CLM

    23,791
    183
    Dec 28, 2000
    Well, hell. That eliminates a lot of the ones I know.

    Have you looked at the automagic cleaning that WIN has built into it? Disk cleanup or something like that. It has a setting that you can delete, compress, or other things files that have not been touched in XXX days.

    DanH
     
  6. gwalchmai

    gwalchmai Lucky Member

    24,129
    708
    Jan 9, 2002
    Outside the perimeter
    No, I haven't, but that's a good suggestion. I tend to not look at Windows built-in utilities most of the time... ;)
     
  7. HerrGlock

    HerrGlock Scouts Out CLM

    23,791
    183
    Dec 28, 2000
    With good reason. But even as sooner or later a blind hog finds an acorn, MS screws up and puts something that actually is useful and generally tends NOT to screw up your machine in with the OS.

    Don't tell 'em, they'll put a castrated version out next time and try to charge you to upgrade to the full version.

    DanH
     
  8. GTIMANiac

    GTIMANiac

    77
    0
    Jul 14, 2001
  9. Tennessee Slim

    Tennessee Slim Señor Member CLM

    4,413
    0
    Apr 14, 2004
    Mucus City, USA
    I did this in my last job using native tools on a *NIX share hosted by VisionFS (which Windblows sees as a Win32 directory). GNU has those same *NIX tools ported for Win32 that should work.

    What I did was run a ‘find’ command to look for files last modified more than 7 days ago. Then redirect the output to a ‘for’ statement to delete them.

    Knowing that some knucklehead eventually would let a file get deleted that was essential to the survival of western civilization, I didn’t delete the files initially but moved them to a directory called “DeathRow” that was inaccessible to the user (but I never let the clients know). A similar script running on DeathRow deleted any file left there more than a month, giving them a 30-day grace period to notice the file had disappeared from the network share.

    You can get the GNU DOS tools (free) at http://unxutils.sourceforge.net or http://userpage.fu-berlin.de/~wbg/unixdos.html.
     
  10. gwalchmai

    gwalchmai Lucky Member

    24,129
    708
    Jan 9, 2002
    Outside the perimeter
    GTI and Slim, those look good. I'll look them over later. We moved the office two weeks ago and these kinds of things are getting tiny timeslices in between the constant "where's my printer?!!" crises. ;f

    Thanks a bunch!
     
  11. GTIMANiac

    GTIMANiac

    77
    0
    Jul 14, 2001
    Heh I work at the Amex Data Center, I own 150 windows boxes,trust me I know all about putting out fires, plus I am on call this week. As a Team we have 1500.

    Cygwin is full of tools, though I would never install it on a production box. Same goes for the Resource Kit as well.
     
  12. ngray

    ngray

    54
    0
    Feb 3, 2005
    Port Richey, FL
    Simplest way is to simply empty the folder on the first of every month, but retain a trailing month.

    1) Clear out /pub/LastMonthsBackup
    2) Move /pub/*.* to /pub/LastMonthsBackup
    3) RD /pub/LastMonthsBackup/LastMonthsBackup

    Just run this on the 1st of every month. All you need is a scheduled task, a batch file, and xcopy.
     
  13. Tennessee Slim

    Tennessee Slim Señor Member CLM

    4,413
    0
    Apr 14, 2004
    Mucus City, USA
    ...is not the Geek Way. In the interest of job security, it is essential that no one else in the shop be able to follow your scripts (without investing an inordinate amount of time). ;N

    If there are any questions, Dogpile (I don’t Google) ...Dogpile for “how to's” on “unmaintainable code”. Here‘s one I find particularly effective.
     
  14. David_G17

    David_G17 /\/\/\/\/\/\/\/

    2,046
    0
    Oct 7, 2002
    code obfuscation == job security
     
  15. srhoades

    srhoades

    2,800
    10
    Jul 14, 2000
    :gasp: He's like Wally's apprentice!
     
  16. gwalchmai

    gwalchmai Lucky Member

    24,129
    708
    Jan 9, 2002
    Outside the perimeter
    YES! Very Good! I am reminded of my friend Richard, who, in the late '80s, wrote a 1000 line batch file for installing NetWare. Essentially it ran setup.exe, but oh, what a fun time it had while doing it. ;f
     
  17. GTIMANiac

    GTIMANiac

    77
    0
    Jul 14, 2001
    You could move a file that is only a day old then. Also check out robocopy instead of XCopy for large directory transfers or replication. I replicate several gigs a night without fail and write it out to a log file.
     
  18. Toyman

    Toyman

    2,597
    20
    May 6, 2003
    West Michigan
    Files have 3 dates, Created, Modified, and Accessed. When the file is copied to the shared folder, the created date will be when that took place, the modified date will be the date it was last modified and is the date normally displayed in Windows Explorer.

    In Windows Explorer, if you choose View->Details then right click on the header (Name, Size, Type, Date...) you will be presented with a context menu of what items you want to display. By default, the Modified Date is displayed, but you could choose Created Date and manually sort and remove items.

    If that doesn't work for you, let me know and I could write a program that would do it automatically.
     
  19. gwalchmai

    gwalchmai Lucky Member

    24,129
    708
    Jan 9, 2002
    Outside the perimeter
    Yes, I can use the created date programmatically. I was wondering if there was a util available.
     
  20. Tennessee Slim

    Tennessee Slim Señor Member CLM

    4,413
    0
    Apr 14, 2004
    Mucus City, USA
    The GNU 'find' command for Win32 has most of the functionality of its *NIX counterpart, meaning it will search for (among other things), when created, last time accessed or modified.