1

How do I strip the content of a file without removing the file itself in a windows scripting environment?

4
  • Found the Clear-Content cmdlet usable with Windows PowerShell. technet link Does exactly what I want.
    – Erik B
    Dec 3, 2012 at 8:38
  • 1
    If that solved your issue, we prefer you post it as an answer and accept it (when you can). Dec 3, 2012 at 11:40
  • When you use a term like "scripting environment" at least tell us what scripting language. Dec 4, 2012 at 5:47
  • Well, at the time I asked the question, any scripting language executable in a windows environment would do.
    – Erik B
    Jan 7, 2013 at 13:41

1 Answer 1

1

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   
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .