Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
1  
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
add 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   
    }
}
share|improve this answer
add comment

Your Answer

 
discard

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.