brename v2.6.0
Changelog
- better conflict detection
- add flag
-o/--overwrite-mode
to choose 0) reporting error, 1) overwriting existed files or 2) skipping renaming.
Example
$ ls *.tar.gz
brename_darwin_386.tar.gz brename_linux_386.tar.gz brename_windows_386.exe.tar.gz
brename_darwin_amd64.tar.gz brename_linux_amd64.tar.gz brename_windows_amd64.exe.tar.gz
-
default mode: reporting error
$ brename -p 386 -r amd64 -d [ERRO] checking: [ new path existed ] 'brename_darwin_386.tar.gz' -> 'brename_darwin_amd64.tar.gz' [ERRO] checking: [ new path existed ] 'brename_linux_386.tar.gz' -> 'brename_linux_amd64.tar.gz' [ERRO] checking: [ new path existed ] 'brename_windows_386.exe.tar.gz' -> 'brename_windows_amd64.exe.tar.gz' [ERRO] 3 potential error(s) detected, please check
-
allowing overwrite
$ brename -p 386 -r amd64 -d -o 1 [WARN] checking: [ new path existed ] 'brename_darwin_386.tar.gz' -> 'brename_darwin_amd64.tar.gz' (will be overwrited) [WARN] checking: [ new path existed ] 'brename_linux_386.tar.gz' -> 'brename_linux_amd64.tar.gz' (will be overwrited) [WARN] checking: [ new path existed ] 'brename_windows_386.exe.tar.gz' -> 'brename_windows_amd64.exe.tar.gz' (will be overwrited) [INFO] 3 path(s) to be renamed
-
leave it
$ brename -p 386 -r amd64 -d -o 2 [WARN] checking: [ new path existed ] 'brename_darwin_386.tar.gz' -> 'brename_darwin_amd64.tar.gz' (will NOT be overwrited) [WARN] checking: [ new path existed ] 'brename_linux_386.tar.gz' -> 'brename_linux_amd64.tar.gz' (will NOT be overwrited) [WARN] checking: [ new path existed ] 'brename_windows_386.exe.tar.gz' -> 'brename_windows_amd64.exe.tar.gz' (will NOT be overwrited) [INFO] 0 path(s) to be renamed
-
this flag also works for another case, where two or more files are renamed to same new path
$ brename -f 386 -p 'darwin|linux' -r unix-like -d [INFO] checking: [ ok ] 'brename_darwin_386.tar.gz' -> 'brename_unix-like_386.tar.gz' [ERRO] checking: [ overwriting newly renamed path ] 'brename_linux_386.tar.gz' -> 'brename_unix-like_386.tar.gz' [ERRO] 1 potential error(s) detected, please check $ brename -f 386 -p 'darwin|linux' -r unix-like -d -o 1 [INFO] checking: [ ok ] 'brename_darwin_386.tar.gz' -> 'brename_unix-like_386.tar.gz' [WARN] checking: [ overwriting newly renamed path ] 'brename_linux_386.tar.gz' -> 'brename_unix-like_386.tar.gz' (will be overwrited) [INFO] 2 path(s) to be renamed $ brename -f 386 -p 'darwin|linux' -r unix-like -d -o 2 [INFO] checking: [ ok ] 'brename_darwin_386.tar.gz' -> 'brename_unix-like_386.tar.gz' [WARN] checking: [ overwriting newly renamed path ] 'brename_linux_386.tar.gz' -> 'brename_unix-like_386.tar.gz' (will NOT be overwrited) [INFO] 1 path(s) to be renamed