Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Problems identifying Hidden files and deleting them from an imported list

$
0
0

Hey all.. 

I received a list of files from a customer and i'm  importing the list as a csv and then identifying if they are there and then deleting them.  One problem, it's not picking up the hidden files properly and is identifying them as not being there..

 

Here's the code

 

 

$i= ipcsv c:\file.csv | select new_path
$i | % {
$srcpath=$_."new_path"
if (gci $srcpath-ea"silentlycontinue") {
ac -path c:\temp\deleted_files.txt-value"Found path: $srcpath deleted"
del $srcpath-whatif
} else {
ac -path c:\temp\files_not_exist.txt-value"Path: $srcpath Not found" }
}
I have tried gci -attributes hidden, but it's not working the way i expected
any help would be greatly appreciated

Viewing all articles
Browse latest Browse all 6937

Trending Articles