func (fileMover FileMover) DeleteEmptyDirectories(dirPath string) error {
	if !fileMover.isDryRun {
		fileNames, err := ioutil.ReadDir(dirPath)
		if err != nil {
			return err
		}
		for _, entry := range fileNames {
			if entry.IsDir() {
				childDirPath := filepath.Join(dirPath, entry.Name())
				err := fileMover.DeleteEmptyDirectories(childDirPath)
				if err != nil {
					log.Println("[WARN]", "Failed to delete directory", childDirPath, ":", err)
				}
			}
		}
		log.Println("[INFO]", "Attempting to delete directory ", dirPath)
		if err := fileMover.writeUndoCommandForDirDelete(dirPath); err != nil {
			return err
		}
		os.Remove(dirPath)
	} else {
		log.Println("[INFO]", "Dryrun deleting directory", dirPath)
	}
	return nil
}
// DeleteEmptyDirectories deletes any empty directories that can be deleted, rooted at the specified directory.
DeleteEmptyDirectories deletes any empty directories that can be deleted, rooted at the specified directory.
// DeleteEmptyDirectories deletes any empty directories that can be deleted rooted at the specified directory .
func (fileMover FileMover) DeleteEmptyDirectories(dirPath string) error {
	if !fileMover.isDryRun {
		fileNames, err := ioutil.ReadDir(dirPath)
		if err != nil {
			return err
		}
		for _, entry := range fileNames {
			if entry.IsDir() {
				childDirPath := filepath.Join(dirPath, entry.Name())
				err := fileMover.DeleteEmptyDirectories(childDirPath)
				if err != nil {
					log.Println("[WARN]", "Failed to delete directory", childDirPath, ":", err)
				}
			}
		}
		log.Println("[INFO]", "Attempting to delete directory ", dirPath)
		if err := fileMover.writeUndoCommandForDirDelete(dirPath); err != nil {
			return err
		}
		os.Remove(dirPath)
	} else {
		log.Println("[INFO]", "Dryrun deleting directory", dirPath)
	}
	return nil
}
func ( fileMover FileMover ) DeleteEmptyDirectories ( dirPath string ) error { if ! fileMover . isDryRun { fileNames , err := ioutil . ReadDir ( dirPath ) if err != nil { return err } for _ , entry := range fileNames { if entry . IsDir ( ) { childDirPath := filepath . Join ( dirPath , entry . Name ( ) ) err := fileMover . DeleteEmptyDirectories ( childDirPath ) if err != nil { log . Println ( " " , " " , childDirPath , " " , err ) } } } log . Println ( " " , " " , dirPath ) if err := fileMover . writeUndoCommandForDirDelete ( dirPath ) ; err != nil { return err } os . Remove ( dirPath ) } else { log . Println ( " " , " " , dirPath ) } return nil }
DeleteEmptyDirectories deletes any empty directories that can be deleted, rooted at the specified directory.
DeleteEmptyDirectories deletes any empty directories that can be deleted rooted at the specified directory .