blob: f300a397abb9b64cd91ebcee760aa9c34323fc0a [file] [log] [blame]
package main
import (
"os"
"path/filepath"
"go.skia.org/infra/go/common"
"go.skia.org/infra/go/fileutil"
"go.skia.org/infra/go/sklog"
)
func main() {
common.Init()
fileInfos, err := os.ReadDir(".")
if err != nil {
sklog.Fatalf("Unable to read directory.")
}
// Get the directory
for _, info := range fileInfos {
if info.IsDir() {
continue
}
fileName := info.Name()
outFileName := fileutil.TwoLevelRadixPath(fileName)
if fileName == outFileName {
sklog.Infof("Excluding %s -> %s", fileName, outFileName)
continue
}
if !fileutil.FileExists(outFileName) {
// Create the path if it doesn't exist.
targetDir, _ := filepath.Split(outFileName)
if err = os.MkdirAll(targetDir, 0700); err != nil {
sklog.Errorf("Unable to run create path: %s", targetDir)
}
if err := os.Rename(fileName, outFileName); err != nil {
sklog.Errorf("Unable to run mv %s %s", fileName, outFileName)
}
}
}
}