Hi
Here is the situation
I have a folder and there are 100 folders and in all 100 folders there are random number of text files i.e. in some folder there are 50+ text and in some 200+ text files.
I want to delete from all text file from all 100 folders except 1st 20 files.
I can do this by this command at powershell
gci path | sort CreationTime | select -Skip 20| Remove-Item -Force
path = my folder location
It deletes all text file except 1st 20 files but I have to change every time the path.
Is there is any option that command delete all files from every folder except 1st 20 files from each folder.
Here is the situation
I have a folder and there are 100 folders and in all 100 folders there are random number of text files i.e. in some folder there are 50+ text and in some 200+ text files.
I want to delete from all text file from all 100 folders except 1st 20 files.
I can do this by this command at powershell
gci path | sort CreationTime | select -Skip 20| Remove-Item -Force
path = my folder location
It deletes all text file except 1st 20 files but I have to change every time the path.
Is there is any option that command delete all files from every folder except 1st 20 files from each folder.