You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,9 @@ You only need to start the tool in any directory, and it will open a list of pat
8
8
9
9
When run from inside some directory, this program will:
10
10
11
-
1. Create a temporary file with a list of all files contained in the given directory and its sub directories
12
-
2. Opens the temporary file with the default editor (For files with the file extension `.batch-rename`)
13
-
3. Reads the file back, and renames/moves the files
11
+
1. Create a temporary file with a list of all files contained in the given directory and its sub directories.
12
+
2. Opens the temporary file with the default editor. (For files with the file extension `.batch-rename`)
13
+
3. Reads the file back, and renames/moves the files.
14
14
15
15
## Usage
16
16
@@ -21,11 +21,19 @@ There are multiple ways to use this tool:
21
21
- Use `go install github.com/Dadido3/batch-rename@latest`. Afterwards you can run `batch-rename` from inside any directory.
22
22
- Build it yourself from source, see below.
23
23
24
+
## Options
25
+
26
+
-`batch-rename --no-numbers` will disable line number output.
27
+
This means that each line contains only the file path without a preceding number, which is easier to edit in some cases.
28
+
Using this option has the downside that any line removal or insertion can mess up the mapping between old and new paths, which can mess up your filenames.
29
+
24
30
## Building
25
31
26
32
This software uses GoReleaser to automatically build and upload artifacts to GitHub.
27
33
Make sure to [install GoReleaser](https://goreleaser.com/install/).
28
34
29
35
- To build for your current platform use `goreleaser build --single-target --clean`. Or `goreleaser build --single-target --snapshot --clean` if you have modified the repository.
30
36
- To simulate the release process, use `goreleaser --skip-publish --auto-snapshot --clean`.
31
-
- To build for your current platform and without GoReleaser, use `go build`. This will not include the version information.
37
+
38
+
To build for your current platform and without GoReleaser, use `go build`.
Copy file name to clipboardExpand all lines: main.go
+20-17Lines changed: 20 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
// Copyright (c) 2021-2022 David Vogel
1
+
// Copyright (c) 2021-2023 David Vogel
2
2
//
3
3
// This software is released under the MIT License.
4
4
// https://opensource.org/licenses/MIT
@@ -7,6 +7,7 @@ package main
7
7
8
8
import (
9
9
"bufio"
10
+
"flag"
10
11
"io/fs"
11
12
"log"
12
13
"os"
@@ -15,10 +16,15 @@ import (
15
16
"github.com/skratchdot/open-golang/open"
16
17
)
17
18
19
+
varflagNoNumbers=flag.Bool("no-numbers", false, "If set, batch-rename will not prepend numbers to every line. If you enable this option you have to make sure that you don't add or remove lines, as otherwise it will mess up your filenames!")
20
+
18
21
funcmain() {
22
+
flag.Parse()
23
+
19
24
log.Printf("Started batch-rename %v", Version)
20
25
21
26
rootDir:="."
27
+
numbering:=!*flagNoNumbers
22
28
23
29
fileEntries:= []fileEntry{}
24
30
@@ -51,51 +57,48 @@ func main() {
51
57
return
52
58
}
53
59
54
-
log.Printf("Got %d files to rename", len(fileEntries))
0 commit comments