수백 개의 사진, 비디오, 음원, 소스 코드 파일의 이름을 다룰 때 단순한 '찾아 바꾸기'만으로는 한계에 부딪히게 됩니다. 예를 들어 `IMG_20260803_123456.jpg` 형태의 날짜 텍스트를 `2026-08-03_IMG_123456.jpg`로 변경하거나, 파일명 중간에 위치한 불필요한 대괄호 태그(`[HD]`, `[4K]`)를 일괄 제거하는 작업은 단순한 접두사/접미사 추가만으로 불가능합니다.
이러한 복잡한 파일명 정리 작업에 필요한 핵심 도구가 바로 정규 표현식(Regular Expression, Regex)입니다. 본 기술 블로그에서는 배처 툴(Batcher Tools)의 이름 변경 탭에서 활용 가능한 대표적인 정규식 패턴과 실전 응용법을 상세히 다룹니다.
정규표현식은 특정한 규칙을 가진 문자열의 집합을 표현하는 데 사용되는 형식 언어입니다. 일반적인 찾아 바꾸기가 고정된 텍스트("apple" -> "banana")만 매칭하는 반면, 정규식은 "4자리 숫자 뒤에 오일 하이픈과 2자리 숫자가 오는 구조"와 같은 패턴(Pattern)을 감지할 수 있습니다.
배처 툴에서의 정규식 지원: 배처 툴의 '문자열 치환(Replace)' 규칙 옵션에서 [정규식 사용] 체크박스를 활성화하면 자바스크립트 엔진 기반의 강력한 정규식 치환 기능이 동작합니다.
| 목적 | 검색 패턴 (Search Regex) | 치환 패턴 (Replace Pattern) | 변경 전후 예시 |
|---|---|---|---|
| 날짜 위치 변경 | (\d{4})-(\d{2})-(\d{2})_(.*) |
$1_$2_$3_$4 |
2026-08-03_photo.jpg →2026_08_03_photo.jpg |
| 대괄호 태그 삭제 | \[.*?\]\s* |
(빈 값) | [HD] [Final] sample.mp4 →sample.mp4 |
| 특수문자 통일 | [\s\-_]+ |
_ |
my file - name--v2.png →my_file_name_v2.png |
| 숫자 부분 보존 | .*?(\d+).* |
item_$1 |
IMG_0042_final.jpg →item_0042.jpg |
| 소문자 및 뱀체(snake_case)화 | ([a-z])([A-Z]) |
$1_$2 |
camelCaseName.js →camel_Case_Name.js |
정규식의 가장 위력적인 기능은 소괄호 `()`를 사용하여 매칭된 특정 부위를 묶어두는 캡처 그룹입니다.
예를 들어 검색 패턴으로 ([0-9]{4})_([a-zA-Z]+)를 입력하면:
([0-9]{4})에 걸린 4자리 숫자가 변수 $1에 저장됩니다.([a-zA-Z]+)에 걸린 영문자가 변수 $2에 저장됩니다.치환할 문자열 항목에 $2_$1이라고 작성하면 원래 순서였던 "숫자_문자" 구조가 "문자_숫자" 순서로 완벽하게 뒤바뀌게 됩니다.
안전장치: 실수로 잘못된 정규식을 입력하여 이름이 꼬이더라도 'Undo(실행 취소)' 버튼이나 'Reset(전체 복원)' 버튼을 눌러 언제든지 안전하게 원본 상태로 복구할 수 있습니다.
When organizing hundreds of image, video, audio, or codebase files, standard string search-and-replace often falls short. For instance, converting dates formatted like `IMG_20260803_123456.jpg` to `2026-08-03_IMG_123456.jpg`, or stripping away bracketed metadata tags like `[HD]` and `[4K]` requires more than simple prefixing.
The core solution for complex bulk renaming is Regular Expressions (Regex). This technical blog covers fundamental patterns and practical guides for using Regex inside Batcher Tools.
A Regular Expression is a specialized sequence of characters that defines a search pattern. Unlike basic search matching that checks literal text, Regex matches flexible structures such as "a 4-digit number followed by a hyphen and two digits".
Regex in Batcher Tools: Enabling the [Use Regex] option in the Replace rule panel unlocks client-side Javascript Regex parsing.
| Use Case | Search Regex | Replace Pattern | Before / After Example |
|---|---|---|---|
| Reorder Date Format | (\d{4})-(\d{2})-(\d{2})_(.*) |
$1_$2_$3_$4 |
2026-08-03_photo.jpg →2026_08_03_photo.jpg |
| Strip Bracket Tags | \[.*?\]\s* |
(Empty) | [HD] [Final] sample.mp4 →sample.mp4 |
| Unify Separators | [\s\-_]+ |
_ |
my file - name--v2.png →my_file_name_v2.png |
| Extract Digits Only | .*?(\d+).* |
item_$1 |
IMG_0042_final.jpg →item_0042.jpg |
| Camel to Snake Case | ([a-z])([A-Z]) |
$1_$2 |
camelCaseName.js →camel_Case_Name.js |
Capturing groups use parentheses `()` to store matched sub-patterns into backreference variables.
For example, using search pattern ([0-9]{4})_([a-zA-Z]+) stores:
$1$2Setting the replacement to $2_$1 cleanly swaps the target pattern order in real time.
Failsafe: If an unintended Regex pattern alters filenames incorrectly, click 'Undo' or 'Reset' to instantly restore original filenames on disk.