I would use python for file related things but sure no problem heres some very quick and dirty code (select all objects object to be exported):
{
$fileName = (`internalVar -userTmpDir` + "example2.skin");
$fileId=`fopen $fileName "w"`;
for ($item in `ls -sl`){
$skin = findRelatedSkinCluster($item);
// windows style endings
fprint $fileId ("weights for cluster " + $skin +":\r\n");
for ($vert in `ls -fl ($item + ".vtx[ * ]")`){
float $weights[] = (`skinPercent -query -value skinCluster1 $vert`);
for ($weight in $weights){
fprint $fileId ($weight + "\t");
}
fprint $fileId ("\r\n");
}
}
fclose $fileId;
}
You could be much faster and elegant with maya api and python.