How to Delete Inside of Sub Folders / Directories?

Today I write a very simple Powershell script in order to delete the contents of the sub directories of a directory.

#Parent directory that you will delete the contents of its sub directories
$dir = 'c:\Users\sarp\findthefashion\'

#Foreach sub directory delete all the contents.
Get-ChildItem $dir | ForEach-Object{
$dirToDel = ($dir + $_.name + '\*')
Remove-Item $dirToDel -Recurse
}

5 minutes of scripting saved my 20 minutes of handwork and then I was able to write this entry.

Comments

Popular posts from this blog

AWS encryption chart (SSE-S3 vs SSE-KMS vs SSE-C)

Is Wharton Business Foundations Specialization Good?

Sending Large Data with JSON