pkg

package
v0.0.0-...-6cdb845 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCreateDate = errors.New("given file doesn't have a CreateDate field or we failed to find it")

Functions

func DirSize

func DirSize(path string) (int64, error)

func RemoveDuplicateStr

func RemoveDuplicateStr(strSlice []string) []string

func ResultLog

func ResultLog(extensions int, o *Operator, startTime time.Time)

func ValidateDir

func ValidateDir(dirp string) error

Types

type CSVLogger

type CSVLogger struct {
	// contains filtered or unexported fields
}

CSVLogger writes log entries into a CSV file with three columns: sourceFileName, destinationFileName, SUCCESS/FAILURE.

func NewCSVLogger

func NewCSVLogger(path string) (*CSVLogger, error)

NewCSVLogger creates or truncates a CSV file and writes the header row.

func (*CSVLogger) Close

func (l *CSVLogger) Close() error

func (*CSVLogger) Log

func (l *CSVLogger) Log(status, source, fileName, destination string) error

Log writes single entry into the CSV file.

type Config

type Config struct {
	Rules    []Rule   `yaml:"rules"`
	Override Override `yaml:"override"`
}

func ReadCategories

func ReadCategories(path string) (*Config, error)

type Flags

type Flags struct {
	SrcPath  string
	DstPath  string
	RulePath string
	LogPath  string
	DryRun   bool
	Async    bool
	Verbose  bool
	Pattern  string
}

func GetFlags

func GetFlags(args []string) Flags

type Operator

type Operator struct {
	Storage        Storage
	Flags          Flags
	CsvHandler     *CSVLogger
	SubDirCount    int
	ExtensionCount int
	// contains filtered or unexported fields
}

func GetNewOperator

func GetNewOperator() (*Operator, error)

func (*Operator) AddType

func (o *Operator) AddType(ext, fp string) string

AddType adds and returns category of the file

func (*Operator) AsyncProcessDir

func (o *Operator) AsyncProcessDir(dirpath string, r bool) (int, error)

func (*Operator) BuildStorageMaps

func (o *Operator) BuildStorageMaps(c *Config)

func (*Operator) Copy

func (o *Operator) Copy(dstPath, dstDir, specialDir, fileAbsolutePath string) error

func (*Operator) CreateSubdirs

func (o *Operator) CreateSubdirs(dstBasePath string, rules []Rule) error

func (*Operator) GetExtensionCategory

func (o *Operator) GetExtensionCategory(ext string) (string, bool)

func (*Operator) GetSeparateSubdirs

func (o *Operator) GetSeparateSubdirs(category, ext string) string

func (*Operator) GetSortSubDirs

func (o *Operator) GetSortSubDirs(category string) (string, bool)

func (*Operator) Operate

func (o *Operator) Operate() (int, error)

func (*Operator) ProcessDir

func (o *Operator) ProcessDir(dirpath string, r bool) (int, error)

type Override

type Override struct {
	Priority []string `yaml:"priority_order,omitempty"`
}

type Rule

type Rule struct {
	Category     string   `yaml:"category"`
	Separate     []string `yaml:"separate"`
	Extensions   []string `yaml:"extensions,omitempty"`
	NameContains []string `yaml:"name_contains,omitempty"`
	Sort         string   `yaml:"sort,omitempty"` // month&year is only possible options
}

func (Rule) SeparateExists

func (r Rule) SeparateExists() bool

type Storage

type Storage struct {
	Entries        []os.DirEntry
	Categories     map[string][]string // [categories][]extensions
	Extensions     map[string]string   // [extensions][categories]
	OutDirectories map[string][]string // []categories[files]
	SubDirs        map[string][]string // [subDir][]extensions
	Unprocessed    []string
	SortMap        map[string]string //image:year, videos:month, documents:month
	Exif           *exiftool.Exiftool
}

func NewStorage

func NewStorage() *Storage

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL