Advanced Rules
Advanced Rules
Want intelligent replacements based on filename patterns? Extension got changed and files won't open? Need complex renaming based on file content or size? Advanced rules have you covered.
Rules Overview
| Rule | Function | Visual Example | Use Cases |
|---|---|---|---|
| Conditional Replace | Replace content before/after anchor points | photo_20241225.jpg → img_20241225.jpg | Batch modify characters at specific positions; replace content conditionally |
| Fix Extension | Auto-detect and fix incorrect extensions | archive.zip111 → archive.zip | Fix renamed archives; identify disguised files |
| JS Script Rule | Complex renaming logic with JavaScript | note.txt → project_plan_note.txt | Use file content as filename; intelligent categorization by file size |
Common Combinations (Multi-Rule Pipeline)
Advanced rules are typically used with other rules to complete complex batch operations in one go.
Common Combinations:
-
Fix Extension → Conditional Replace: First fix incorrect extensions, then use anchor points to standardize filename format
Original: photo_001.jpg111, photo_002.jpg111 ↓ Fix Extension (detected as .jpg) photo_001.jpg, photo_002.jpg ↓ Conditional Replace (anchor "_", replace before with "img") img_001.jpg, img_002.jpg -
JS Script → Sequence: First categorize by file size with JS script, then add sequence numbers
Original: report.pdf (5MB), photo.jpg (500KB) ↓ JS Script (add tags based on file size) [MEDIUM]_report.pdf, [SMALL]_photo.jpg ↓ Sequence (3 digits) [MEDIUM]_report_001.pdf, [SMALL]_photo_002.jpg -
Clean → JS Script: First clean garbled characters from filenames, then use JS script to read file content as prefix
Original: ??note.txt (first line content is "Project Plan") ↓ Clean (keep letters and numbers only) note.txt ↓ JS Script (use first line as prefix) project_plan_note.txt
💡 Why use combinations? A single rule might not solve particularly complex naming needs, but combinations can cover more scenarios. For example, first fix extensions, then standardize format, and finally add numbering.
Operation Tips
- 🎯 Think through requirements first: Are you fixing extensions, replacing by rules, or need to read file info for complex decisions?
- 🔍 Test with few files first: Start with 5-10 different files to verify the rule works as expected
- ⚠️ Note file differences: Different files may have different characteristics (some have anchors, some don't; some are archives, some aren't), check preview results
Common Questions
Q: What's the difference between Conditional Replace and JS Script? When to use which?
A:
- Conditional Replace: Suitable for simple text replacement logic, no coding required, easy to configure. For example, "change content before underscore to fixed text"
- JS Script: Suitable for complex renaming logic, needs reading file content, checking file size, performing complex calculations, etc. Requires some JavaScript knowledge
Recommendation: If Conditional Replace can solve it, use Conditional Replace - it's simpler. Only consider JS Script for complex needs that Conditional Replace can't handle.
Q: Will Fix Extension modify the actual file content?
A: Absolutely not. The Fix Extension rule only modifies the filename (extension part), without reading or modifying the actual file content. It identifies the real type by reading the file header's "magic number" (file type signature), then corrects the extension part of the filename.
Your file content is completely safe.
Q: Processing many files is slow, how to optimize?
A: Different rules have different performance characteristics:
- Conditional Replace: Very fast, pure text processing, doesn't read files
- Fix Extension: Needs to read each file's header data, slower with many files (but has caching mechanism)
- JS Script: Depends on your code logic, will be slower if involving file reads (
api.readTextFile)
Optimization suggestions:
- Process in batches: Handle 50-100 files at a time instead of thousands at once
- Verify logic with preview first, then process in bulk
- Avoid unnecessary file read operations in JS scripts
Q: Can I use multiple advanced rules simultaneously?
A: Yes! Rules execute in the order you add them. For example:
Rule 1: Fix Extension → Change .zip111 to .zip
Rule 2: Conditional Replace → Change content before underscore to "backup"
Rule 3: Sequence → Add 001, 002 numbering
Final result: photo_data.zip111 → backup_data_001.zipEach rule processes based on the filename modified by the previous rule. It's recommended to verify the entire process with preview first to avoid rule conflicts.
💡 Click on rule names above to view detailed usage and more examples for each rule.