Skip to content

Commit

Permalink
release dirRenameCopy tagClassification
Browse files Browse the repository at this point in the history
  • Loading branch information
纯真Ccc committed Oct 2, 2021
1 parent 6a61751 commit 681b52b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 21 deletions.
31 changes: 17 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Build
run: mkdir release|| go build -v ./... -o ./release/tidy-files-script-linux-64
- name: Build-dirRenameCopy
run: mkdir release||cd ./dirRenameCopy || go get || go build -o ../release/dirRenameCopy

- name: Create a Release
if: ${{ github.event.inputs.releaseVersion != '' }}
uses: elgohr/Github-Release-Action@main
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
args: "v0.0.1"
- name: Build-tagClassification
run: mkdir release||cd ./tagClassification || go get || go build -o ../release/tagClassification

- name: Create a Release
if: ${{ github.event.inputs.releaseVersion != '' }}
uses: elgohr/Github-Release-Action@main
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
args: "v0.0.2"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
# golang
/pkg
http-client.private.env.json
go.sum
7 changes: 6 additions & 1 deletion dirRenameCopy/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module github.com/daizc311/TidyFilesScript/dirRenameCopy

require github.com/sirupsen/logrus v1.8.1
require (
github.com/daizc311/TidyFilesScript/config v0.0.0
github.com/sirupsen/logrus v1.8.1
)

replace github.com/daizc311/TidyFilesScript/config => ../config

go 1.16
18 changes: 14 additions & 4 deletions dirRenameCopy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"container/list"
"github.com/daizc311/TidyFilesScript/config"
log "github.com/sirupsen/logrus"
"os"
"strings"
"github.com/daizc311/TidyFilesScript/config"
"syscall"
"time"
)

Expand All @@ -23,15 +24,13 @@ var suffixList = func() *list.List {
func main() {
config.InitLog()
log.SetFormatter(config.JsonLogFormatter())
currentPath = "F:\\test"
scanDirList(currentPath)

}

func getSuffix(fileName string) string {
for i := suffixList.Front(); i != nil; i = i.Next() {

if strings.HasSuffix(fileName, i.Value.(string)) {
if strings.HasSuffix(strings.ToLower(fileName), i.Value.(string)) {
return i.Value.(string)
}
}
Expand Down Expand Up @@ -63,12 +62,21 @@ func scanDirList(dirPath string) {
continue
}
moveFile(originalFilePath, targetFilePath)
rmDir(path)
}
}
}
}
}

func rmDir(path string) {
log.Infof("开始删除目录=>\n目标路径: %s", path)
err := syscall.Rmdir(path)
if err != nil {
log.Errorf("删除目录失败: %s", err.Error())
}
}

func moveFile(originalFilePath string, targetFilePath string) {
log.Infof("开始移动文件=>\n当前文件路径: %s \n目标文件路径: %s", originalFilePath, targetFilePath)
err := os.Rename(originalFilePath, targetFilePath)
Expand All @@ -78,12 +86,14 @@ func moveFile(originalFilePath string, targetFilePath string) {
}

func getTargetDirByDate(path string, now time.Time) (string, error) {

dateStr := now.Format("20060102")
dirPath := path + string(os.PathSeparator) + dateStr

var _, err = os.Stat(dirPath)
if err != nil {
if os.IsNotExist(err) {
log.Infof("目录不存在,创建输出目录=>\n目标路径: %s", dirPath)
err := os.Mkdir(dirPath, os.ModePerm)
if err != nil {
return dirPath, err
Expand Down
Binary file added release/dirRenameCopy.exe
Binary file not shown.
Binary file added release/tagClassification.exe
Binary file not shown.
7 changes: 6 additions & 1 deletion tagClassification/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module github.com/daizc311/TidyFilesScript/tagClassification

require github.com/sirupsen/logrus v1.8.1
require (
github.com/daizc311/TidyFilesScript/config v0.0.0
github.com/sirupsen/logrus v1.8.1
)

replace github.com/daizc311/TidyFilesScript/config => ../config

go 1.16
2 changes: 1 addition & 1 deletion tagClassification/mian.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main

import (
"github.com/daizc311/TidyFilesScript/config"
log "github.com/sirupsen/logrus"
"os"
"path"
"regexp"
"strings"
"tidy-files-script/config"
)

// 获取相对路径
Expand Down

0 comments on commit 681b52b

Please sign in to comment.