Compare commits
3 Commits
ce8ff24684
...
bb1d56c950
Author | SHA1 | Date | |
---|---|---|---|
bb1d56c950 | |||
882713359d | |||
a9b9e06324 |
19
install_context_menu.reg
Normal file
19
install_context_menu.reg
Normal file
@@ -0,0 +1,19 @@
|
||||
Windows Registry Editor Version 5.00
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\Group by date]
|
||||
@="Group by date"
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\Group by date\command]
|
||||
@="C:\\Users\\administrator\\go\\bin\\dategrouper.exe \"%1\""
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\*\shell\Group by date]
|
||||
@="Group by date"
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\*\shell\Group by date\command]
|
||||
@="C:\\Users\\administrator\\go\\bin\\dategrouper.exe \"%1\""
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\AllFileSystemObjects\shell\Group by date]
|
||||
@="Group by date"
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\AllFileSystemObjects\shell\Group by date\command]
|
||||
@="C:\\Users\\administrator\\go\\bin\\dategrouper.exe %*"
|
23
main.go
23
main.go
@@ -44,6 +44,7 @@ func (dp *DateParserISO) Parse(s string) (time.Time, error) {
|
||||
func main() {
|
||||
flag.Parse()
|
||||
logger.InitFlag()
|
||||
logger.Default = logger.Default.ToFile("dategrouper.log")
|
||||
|
||||
if flag.NArg() == 0 {
|
||||
logger.Error("no files provided")
|
||||
@@ -57,7 +58,6 @@ func main() {
|
||||
|
||||
files := flag.Args()
|
||||
|
||||
|
||||
cyutils.WithWorkers(10, files, func(worker int, _ int, file string) {
|
||||
workerlog := logger.Default.WithPrefix(fmt.Sprintf("worker=%d", worker))
|
||||
filelog := workerlog.WithPrefix(fmt.Sprintf("file=%q", file))
|
||||
@@ -68,25 +68,23 @@ func main() {
|
||||
return
|
||||
}
|
||||
filelog.Info("date: %s", date)
|
||||
|
||||
datedir := fmt.Sprintf("%04d-%02d-%02d", date.Year(), date.Month(), date.Day())
|
||||
dest := filepath.Join(datedir, file)
|
||||
|
||||
dir := filepath.Dir(file)
|
||||
datedir := filepath.Join(dir, fmt.Sprintf("%04d-%02d-%02d", date.Year(), date.Month(), date.Day()))
|
||||
dest := filepath.Join(datedir, filepath.Base(file))
|
||||
filelog.Info("dest: %s", dest)
|
||||
err = os.MkdirAll(datedir, 0755)
|
||||
if err != nil {
|
||||
filelog.Error("error creating directory: %s", err)
|
||||
return
|
||||
}
|
||||
// Make sure file doesn't exist
|
||||
destfile, err := os.Stat(dest)
|
||||
if err == nil {
|
||||
filelog.Info("dest file already exists: %s", destfile.Name())
|
||||
return
|
||||
} else {
|
||||
if !os.IsNotExist(err) {
|
||||
filelog.Error("error checking dest file: %s", err)
|
||||
return
|
||||
}
|
||||
} else if !os.IsNotExist(err) {
|
||||
filelog.Error("error checking dest file: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
filelog.Debug("opening input file")
|
||||
@@ -99,16 +97,17 @@ func main() {
|
||||
out, err := os.Create(dest)
|
||||
if err != nil {
|
||||
filelog.Error("error creating dest file: %s", err)
|
||||
in.Close()
|
||||
return
|
||||
}
|
||||
filelog.Info("copying file")
|
||||
_, err = io.Copy(out, in)
|
||||
in.Close()
|
||||
out.Close()
|
||||
if err != nil {
|
||||
filelog.Error("error copying file: %s", err)
|
||||
return
|
||||
}
|
||||
in.Close()
|
||||
out.Close()
|
||||
|
||||
filelog.Info("removing original file")
|
||||
err = os.Remove(file)
|
||||
|
8
uninstall_context_menu.reg
Normal file
8
uninstall_context_menu.reg
Normal file
@@ -0,0 +1,8 @@
|
||||
Windows Registry Editor Version 5.00
|
||||
|
||||
[-HKEY_CURRENT_USER\Software\Classes\Directory\shell\Group by date]
|
||||
[-HKEY_CURRENT_USER\Software\Classes\Directory\shell\Group by date\command]
|
||||
[-HKEY_CURRENT_USER\Software\Classes\*\shell\Group by date]
|
||||
[-HKEY_CURRENT_USER\Software\Classes\*\shell\Group by date\command]
|
||||
[-HKEY_CURRENT_USER\Software\Classes\AllFileSystemObjects\shell\Group by date]
|
||||
[-HKEY_CURRENT_USER\Software\Classes\AllFileSystemObjects\shell\Group by date\command]
|
Reference in New Issue
Block a user