Forum Discussion
Fred_Elmendorf
Apr 12, 2023Copper Contributor
Daily file count in addition to total files in folder.
This script is working well, and providing me the specified information, but in addition to the total file count in each folder, I need the file counts by day for each folder, within the date range. ...
Fred_Elmendorf
Apr 13, 2023Copper Contributor
Hi Andres,
As I was adding your code to mine, and reviewing the output from my file structure, I realized that my problem statement was not correct. For this particular set of folders, new files are added to either the ...\trend or ...\event folder, with the file name constructed to reflect the date of the data contained within the file. I actually have two problems. Number 1, I need to be able to count all the files where the date portion of the file name is the same. Number 2, I need to be able to count all the files where the date portion of the LastWriteTime is the same. Below is an example collection of files from one of the ...\event folders. In this example, 6 files were written on 4/13/2023, 8 fies were written on 4/12/2023, and 15 fies were written on 4/11/2023. However, all of the file names indicate that they contain data from 4/12/2023 (20230412). So, rather than count files in a folder as I had originally described, I actually need one count of files according to their LastWriteTime and another count of files according to the date part of the file name. Thanks again for any help you can provide.
As I was adding your code to mine, and reviewing the output from my file structure, I realized that my problem statement was not correct. For this particular set of folders, new files are added to either the ...\trend or ...\event folder, with the file name constructed to reflect the date of the data contained within the file. I actually have two problems. Number 1, I need to be able to count all the files where the date portion of the file name is the same. Number 2, I need to be able to count all the files where the date portion of the LastWriteTime is the same. Below is an example collection of files from one of the ...\event folders. In this example, 6 files were written on 4/13/2023, 8 fies were written on 4/12/2023, and 15 fies were written on 4/11/2023. However, all of the file names indicate that they contain data from 4/12/2023 (20230412). So, rather than count files in a folder as I had originally described, I actually need one count of files according to their LastWriteTime and another count of files according to the date part of the file name. Thanks again for any help you can provide.
Fred_Elmendorf
Apr 13, 2023Copper Contributor
- Andres-BohrenApr 13, 2023Steel Contributor
For the Files with the Same Modified Date (including hh:mm)
$Files = Get-ChildItem $directory | Where-Object { $_.CreationTime -ge $start -and $_.CreationTime -lt $End } | Group {$_.LastWriteTime.ToString("yyyy-MM-dd hh:mm")} | Sort Name
#Filename: event-YYYYMMDDT >First 16 Characters you want to Compare$Filenames = Get-ChildItem $directory | Where-Object { $_.CreationTime -ge $start -and $_.CreationTime -lt $End } | Group {$_.Name.SubString(0,16)} | Sort Name
How does that work?
Regards
Andres