So I'm trying to show the count of about 40 different folders
Desktop
Documents
MozillaProfiles
Outlook
etc...
My current working theory is
$folder = "C:\users\user\desktop"
$DesktopCount = Get-ChildItem $folder -Force -Recurse -File | Measure-Object | %{$_.Count}
Then at the end of the script I do
$DesktopCount+$DocumentsCount+$DownloadsCount+$FavoritesCount+$LinksCount
Is there a better way of doing this?
Count of Files
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- apowershelluser
- Posts: 194
- Last visit: Fri Mar 22, 2024 4:38 am
Re: Count of Files
I'm trying to provide the count of files of the folders I'm going to move through robocopy and display it to the technician
Then, once the robocopy job is done, I'm going to provide them the count on the new PC
The problem, is not all files are under the users profile so I can't just count that. They are spread throughout the PC so I have to do the individual counts.
Then, once the robocopy job is done, I'm going to provide them the count on the new PC
The problem, is not all files are under the users profile so I can't just count that. They are spread throughout the PC so I have to do the individual counts.
- apowershelluser
- Posts: 194
- Last visit: Fri Mar 22, 2024 4:38 am
Re: Count of Files
$folders = "C:\users\user\desktop","C:\users\user\documents"
$count = $null
foreach ($folder in $folders){
$rclog = robocopy $folder \xxx /L /E
$count += ($rclog -match 'new File' ).Count
}
$count
Looks like a winner!
$count = $null
foreach ($folder in $folders){
$rclog = robocopy $folder \xxx /L /E
$count += ($rclog -match 'new File' ).Count
}
$count
Looks like a winner!
- apowershelluser
- Posts: 194
- Last visit: Fri Mar 22, 2024 4:38 am
Re: Count of Files
Huh? lol
I'll give you some examples of the different folders I'm moving
"C:\users\$user\desktop"
"C:\Users\$user\AppData\Local\Google\Chrome\User Data\Default"
"C:\Users\$user\AppData\Local\Microsoft\Feeds"
"C:\Users\$user\AppData\Local\Microsoft\Internet Explorer\EmieUserList"
"C:\Users\$user\AppData\Roaming\Mozilla\Firefox"
"C:\Users\$user\AppData\Roaming\Microsoft\Outlook"
I'll give you some examples of the different folders I'm moving
"C:\users\$user\desktop"
"C:\Users\$user\AppData\Local\Google\Chrome\User Data\Default"
"C:\Users\$user\AppData\Local\Microsoft\Feeds"
"C:\Users\$user\AppData\Local\Microsoft\Internet Explorer\EmieUserList"
"C:\Users\$user\AppData\Roaming\Mozilla\Firefox"
"C:\Users\$user\AppData\Roaming\Microsoft\Outlook"
- apowershelluser
- Posts: 194
- Last visit: Fri Mar 22, 2024 4:38 am
Re: Count of Files
You need to learn how to use symlinks and mklink.
You should not be doing this over the system folders.
Please don't post images of your code. Post code. The images do not tell us what you are doing.
You should not be doing this over the system folders.
Please don't post images of your code. Post code. The images do not tell us what you are doing.
- apowershelluser
- Posts: 194
- Last visit: Fri Mar 22, 2024 4:38 am
Re: Count of Files
C:\link is considered a system folder?
I've researched a bit this morning and it doesn't look like you can symlink multiple folders to one
I've researched a bit this morning and it doesn't look like you can symlink multiple folders to one