https://github.com/mixcode/normalize-unicode-filename
A command-line utility to rename files in Unicode normalized form
https://github.com/mixcode/normalize-unicode-filename
Last synced: 5 months ago
JSON representation
A command-line utility to rename files in Unicode normalized form
- Host: GitHub
- URL: https://github.com/mixcode/normalize-unicode-filename
- Owner: mixcode
- License: mit
- Created: 2024-10-31T08:15:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-12T12:30:32.000Z (over 1 year ago)
- Last Synced: 2025-03-12T13:29:49.140Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## normalize-unicode-filename: utility to rename files in Unicode normalized form
Some Unicode characters can be represented by different combinations of code points. For example, the e-acute character 'é' can be represented either in a composed form, '\u00e9', or a decomposed form, 'e\u0301'. These forms are theoretically equivalent, but they may lead to differences in actual usage. For instance, macOS typically uses the NFD (decomposed) form for filenames, while Windows generally uses the NFC (composed) form. Due to this discrepancy, filenames can appear completely different across operating systems.
This program renames filenames to their normalized Unicode forms to account for these differences.
### Install
```
$ go install github.com/mixcode/normalize-unicode-filename@latest
```
### Usage
```
Usage: normalize-unicode-filename [option] filename [filename...]
-b shorthand for '-both'
-both
print both original and changed filename
-d shorthand for '-dryrun'
-dryrun
dry-run: do not change file name; print only
-f string
shorthand for '-form'
-form string
Unicode normalization type. One of NFC, NFD, NFKC, NFKD,
or WIN, MAC
-q quiet; do not print filenames
-r recurse subdirectories
```
### Examples
Change filenames in the current directory for the current OS.
If the current os is MacOS, then the default form will be NFD, otherwise NFC.
```
$ normalize-unicode-filename *
```
Change filenames to explicit Windows-friendly form.
```
$ normalize-unicode-filename -form=win *
```
Change filenames to macOS-friendly form, recursively renaming files in its subdirectories.
```
$ normalize-unicode-filename -form=mac -r *
```
Print possible filenames for NFKD form, without changing filenames.
```
$ normalize-unicode-filename -form=NFKD -r -dryrun -both *
```
### Memo
Please note that NFKC and NFKD may cause irreversible changes. Be careful to using them.