func archiveFiles(cfg *conf.Config, dirStr string, rootStat os.FileInfo) (int, error) { count := 0 fileList, err := filepath.Glob(filepath.Join(dirStr, cfg.Pattern)) if err != nil { return 0, err } archiveTime := cfg.ArchiveTime() for _, fname := range fileList { fs, e := os.Stat(fname) if e != nil { fmt.Printf("Error! Failed to consider %s for archiving: %s\n", fname, e) continue } if fs.Name() == conf.ConfName || fs.IsDir() { continue } if fs.ModTime().Before(archiveTime) { if newname, e := archiveFile(fname, cfg, rootStat, fs); e != nil { fmt.Printf("Error! Failed to archive %s - %s\n", fname, e) } else { util.Verbosef("Moved %s --> %s\n", fname, newname) count += 1 } } } return count, nil }