How do I strip the content of a file without removing the file itself in a windows scripting environment?
-
Found the Clear-Content cmdlet usable with Windows PowerShell. technet link Does exactly what I want.– Erik BDec 3, 2012 at 8:38
-
1If that solved your issue, we prefer you post it as an answer and accept it (when you can).– HopelessN00bDec 3, 2012 at 11:40
-
When you use a term like "scripting environment" at least tell us what scripting language.– John GardeniersDec 4, 2012 at 5:47
-
Well, at the time I asked the question, any scripting language executable in a windows environment would do.– Erik BJan 7, 2013 at 13:41
Add a comment
|
1 Answer
Solved this using Windows PowerShell, the cmdlet Clear-Content did the job:
$dirtostrip = "$strippeddir\backup_$backupdate\$backupdate\alf_data\contentstore"
$files=((dir $dirtostrip -recurse) |?{$_.psiscontainer -eq $false})
for ($i=0;$i -ne $files.count; $i++)
{
if ($files[$i] -eq $null) {continue}
if ($files[$i].length -gt $filesizelimit) {
Clear-Content $files[$i].FullName
}
}