728x90
반응형
필자는 가끔 로그나, 윈도우 파일들 정리할 때 rename을 사용하여 정리하곤 한다.
물론 윈도우에서도 파일명 일괄 변경하는 방법이 있다.
아래 명령어로 특정 패턴에 대해서 rename을 해보도록 하자.
rename 패키지 설치
sudo apt install rename
rename 기능
master@master:~/docker2/docker/docker/tmp$ rename --help
Usage:
rename [ -h|-m|-V ] [ -v ] [ -0 ] [ -n ] [ -f ] [ -d ]
[ -e|-E perlexpr]*|perlexpr [ files ]
Options:
-v, --verbose
Verbose: print names of files successfully renamed.
-0, --null
Use \0 as record separator when reading from STDIN.
-n, --nono
No action: print names of files to be renamed, but don't rename.
-f, --force
Over write: allow existing files to be over-written.
--path, --fullpath
Rename full path: including any directory component. DEFAULT
-d, --filename, --nopath, --nofullpath
Do not rename directory: only rename filename component of path.
-h, --help
Help: print SYNOPSIS and OPTIONS.
-m, --man
Manual: print manual page.
-V, --version
Version: show version number.
-e Expression: code to act on files name.
May be repeated to build up code (like "perl -e"). If no -e, the
first argument is used as code.
-E Statement: code to act on files name, as -e but terminated by
';'.
반응형
rename 패턴
rename 's/변경전파일명/변경후파일명/' 대상파일
# 일괄변경 실습
rename 's/test/rename_test/' test_*
rename 실행 시 실제 변경하지 않고, 결과만 보기
-n : 실제로 변경하지 않음(--no-action).
-v : 이름이 변경된 파일이 있는 경우 표시(--verbose).
rename -n -v 's/rename_test/test/' rename_*
728x90
반응형
LIST
'Linux' 카테고리의 다른 글
[Linux] file / type 명령어 사용법 (2) | 2023.02.17 |
---|---|
[Linux] OpenSSL 사설 인증서 발급하기 (2) | 2023.02.16 |
[Linux] 리눅스/라즈베리파이4 외장하드 자동 마운트 설정 (2) | 2023.02.01 |
[Linux] 리눅스/라즈베리파이4 mount 명령어 사용 (6) | 2023.01.31 |
[Linux] curlftpfs 명령어로 원격 FTP 서버를 마운트하여 사용하기 (2) | 2023.01.30 |