none
Script to move log files RRS feed

  • Question


  • Hey yall.

    I have been trying to create a script that moves log files from one folder to another. Which is the easy part. Where i am getting hung up is these files are log files and two of the files have the same name, but one of them is still being written to. The one that is being written to i do not want to be moved until it has completed, which is typically the next day. See the last two files. The last file will not be completed until tomorrow morning at 6:02am, at which time a new file will be created. I have hit a dead end!

    • Moved by Bill_Stewart Monday, December 17, 2018 6:08 PM Unanswerable drive-by question
    Friday, September 28, 2018 4:58 PM

All replies

  • Just copy all of the oldest files.

    $f = Get-ChildItem *.log
    $f  | sort LastWriteTime | select -First ($f.Count -1)


    \_(ツ)_/


    • Edited by jrv Friday, September 28, 2018 5:29 PM
    Friday, September 28, 2018 5:28 PM