close

Privacy guaranteed - Your email is not shared with anyone.

I need a "file aging" utility

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


  1. gwalchmai

    gwalchmai
    Expand Collapse
    Lucky Member

    Joined:
    Jan 9, 2002
    23,961
    492
    Location:
    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!
     

    Wanna kill these ads? We can help!
  2. prism

    prism
    Expand Collapse
    more ammo

    Joined:
    Sep 26, 2002
    1,417
    8
    Location:
    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
    Expand Collapse

    Joined:
    Jul 14, 2000
    2,784
    9
    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
    Expand Collapse

    Joined:
    Jul 14, 2001
    77
    0
  5. HerrGlock

    HerrGlock
    Expand Collapse
    Scouts Out
    CLM

    Joined:
    Dec 28, 2000
    23,791
    179
    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
    Expand Collapse
    Lucky Member

    Joined:
    Jan 9, 2002
    23,961
    492
    Location:
    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
    Expand Collapse
    Scouts Out
    CLM

    Joined:
    Dec 28, 2000
    23,791
    179
    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
    Expand Collapse

    Joined:
    Jul 14, 2001
    77
    0
  9. Tennessee Slim

    Tennessee Slim
    Expand Collapse
    Señor Member
    CLM

    Joined:
    Apr 14, 2004
    4,413
    0
    Location:
    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
    Expand Collapse
    Lucky Member

    Joined:
    Jan 9, 2002
    23,961
    492
    Location:
    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
    Expand Collapse

    Joined:
    Jul 14, 2001
    77
    0
    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
    Expand Collapse

    Joined:
    Feb 3, 2005
    54
    0
    Location:
    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
    Expand Collapse
    Señor Member
    CLM

    Joined:
    Apr 14, 2004
    4,413
    0
    Location:
    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
    Expand Collapse
    /\/\/\/\/\/\/\/

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

    srhoades
    Expand Collapse

    Joined:
    Jul 14, 2000
    2,784
    9
    :gasp: He's like Wally's apprentice!
     
  16. gwalchmai

    gwalchmai
    Expand Collapse
    Lucky Member

    Joined:
    Jan 9, 2002
    23,961
    492
    Location:
    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
    Expand Collapse

    Joined:
    Jul 14, 2001
    77
    0
    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
    Expand Collapse

    Joined:
    May 6, 2003
    2,592
    17
    Location:
    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
    Expand Collapse
    Lucky Member

    Joined:
    Jan 9, 2002
    23,961
    492
    Location:
    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
    Expand Collapse
    Señor Member
    CLM

    Joined:
    Apr 14, 2004
    4,413
    0
    Location:
    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.
     
Loading...
Similar Threads Forum Date
Need help on E file a sbr... General Firearms Forum Jul 9, 2015
Need help with a sound file PLEASE! Tech Talk Jan 19, 2011
recommend a file copy utility Tech Talk Nov 28, 2010
Need to edit a pdf file? Tech Talk Jul 29, 2010
Need a file integrity checker Tech Talk Oct 26, 2009