4
1
# Microsoft Windows [Version 10.0.17134.648]
# powershell 5.1.17134.48
# Calculate time to complete task using Notepad++ "backup on save" feature. Create a copy and paste table of files sorted by LastWriteTime.
# Can be used as a shortcut: powershell -noexit $time = (Get-Date).AddDays(-1); gci * -exclude _*, 1* | where {$_.LastWriteTime -gt $time}| sort -property LastWriteTime -descending | Format-Table LastWriteTime, length, @{n='foo';e={$_.Name -replace '(?<=^.*\.html).*$' -replace '(?<=^.*\.jpg).*$'}} -HideTableHeaders
# start it in %userprofile%\Documents\NOTEPAD++ AUTOBACKUP
Set-Location -Path "$env:userprofile\Documents\NOTEPAD++ AUTOBACKUP"
# how old a file? Today? 4 days old?
$time = (Get-Date).AddDays(-1)
# $time = (Get-Date).AddDays(-4)
# do you want to exclude files with -exclude? Do you want to include with -include?
gci * -exclude _*, 1* | where {$_.LastWriteTime -gt $time}| sort -property LastWriteTime -descending | Format-Table LastWriteTime, length, @{n='foo';e={$_.Name -replace '(?<=^.*\.html).*$' -replace '(?<=^.*\.jpg).*$'}} -HideTableHeaders
gci * -exclude _*, 1* | where {$_.LastWriteTime -gt $time} | sort -property LastWriteTime -descending | Format-Table LastWriteTime, length, Name -HideTableHeaders
# gci * | where {$_.LastWriteTime -gt $time} | sort -property LastWriteTime -descending | Format-Table LastWriteTime, length, @{n='foo';e={$_.Name -replace '(?<=^.*\.html).*$' -replace '(?<=^.*\.jpg).*$'}} -HideTableHeaders
# gci * -include [0-9][0-9][0-9]*, avail* | where {$_.LastWriteTime -gt $time} | sort -property LastWriteTime -descending | Format-Table LastWriteTime, length, @{n='foo';e={$_.Name -replace '(?<=^.*\.html).*$' -replace '(?<=^.*\.jpg).*$'}} -HideTableHeaders
outputs:
5/4/2019 10 : 47 : 27 AM 114036 springhill_falls2bd750_885.jpg
5/4/2019 10 : 45 : 25 AM 1301974 springhill_falls2bd750_885.psp
5/4/2019 10 : 37 : 08 AM 19268 springhill_falls2bd13.html
5/4/2019 10 : 37 : 08 AM 94007 available13.html
5/4/2019 10 : 37 : 08 AM 36729 index.html
5/4/2019 10 : 32 : 16 AM 62801 aj.php
and:
5/4/2019 10 : 47 : 27 AM 114036 springhill_falls2bd750_885.jpg.2019-05-04_104748.bak
5/4/2019 10 : 45 : 25 AM 1301974 springhill_falls2bd750_885.psp.2019-05-04_105221.bak
5/4/2019 10 : 37 : 08 AM 19268 springhill_falls2bd13.html.2019-05-04_105856.bak
5/4/2019 10 : 37 : 08 AM 94007 available13.html.2019-05-04_105657.bak
5/4/2019 10 : 37 : 08 AM 36729 index.html.2019-05-04_105657.bak
5/4/2019 10 : 32 : 16 AM 62801 aj.php.2019-05-04_103229.bak
Microsoft Windows [Version 10.0.17134.648]
powershell 5.1.17134.48
Calculate time to complete task using Notepad++ / NPP / Notepad Plus "backup on save" feature.
Create a copy and paste table of files sorted by LastWriteTime.
Can be used as a shortcut:
powershell -noexit $time = (Get-Date).AddDays(-1); gci * -exclude *, 1* | where {$.LastWriteTime -gt $time}| sort -property LastWriteTime -descending | Format-Table LastWriteTime, length, @{n='foo';e={$_.Name -replace '(?<=^..html).$' -replace '(?<=^..jpg).$'}} -HideTableHeaders
Start it in the directory where your NPP autobackup goes. My files are backed up to %userprofile%\Documents\NOTEPAD++ AUTOBACKUP
This script creates a formatted table output with the edited filenames, size, date and the time each time the file was written to. It is easy to modify which files to search for, how to edit the filenames and how many days old a file you want to search for. It is a convenient way to keep track of how long a file is worked on, how long a task took to complete, how long a project takes.
See LotPings answer below for information about the regex.
@LotPings I choose LotPings answer because it would have been the answer if I had asked a better question. Thanks for taking the time. Your code works. – somebadhat – 2019-04-04T16:49:09.677