fabienfoerster / stow

The thingy to sort my series
0 stars 0 forks source link

Cleanup the folder afterwards #2

Closed fabienfoerster closed 5 years ago

fabienfoerster commented 8 years ago

When the sorting is finish, the source folder may contain a lot of folder that don't contain anything useful. So we must rid of them !

fabienfoerster commented 8 years ago

Should sort what it can, the rest of the video files should in a subfolder toSort, and erase everything in the source folder...

fabienfoerster commented 8 years ago
func RemoveContents(dir string) error {
    d, err := os.Open(dir)
    if err != nil {
        return err
    }
    defer d.Close()
    names, err := d.Readdirnames(-1)
    if err != nil {
        return err
    }
    for _, name := range names {
        err = os.RemoveAll(filepath.Join(dir, name))
        if err != nil {
            return err
        }
    }
    return nil
}