Thursday, January 15, 2015

windows - Delete all files with names longer than 100 characters?


A beta software I installed accidentally created a log file with file name longer than 100 characters in each folder. It's taking a very long time to delete them one by one


Is it possible to bulk delete all the files whose names are longer or equal to 100 characters without deleting files shorter than 100 characters?


Answer



In PowerShell, if this lists your files:


gci -file -recurse | ?{$_.name.length -gt 100} | select name | ft -Wrap

Then this will delete them:


gci -file -recurse | ?{$_.name.length -gt 100} | remove-item

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...