Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
Found the Clear-Content cmdlet usable with Windows PowerShell. technet link Does exactly what I want. – Erik B Dec 3 '12 at 8:38
If that solved your issue, we prefer you post it as an answer and accept it (when you can). – HopelessN00b Dec 3 '12 at 11:40
When you use a term like "scripting environment" at least tell us what scripting language. – John Gardeniers Dec 4 '12 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 '13 at 13:41

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   
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.