Messing around with Python? Nah, it's Go time! 🚀
This is my experiment moving from Python to Golang for CLI tools—so I can finally stop hopping between languages (hopefully).
This little tool helps you rename, move, and organize files like a pro. Just give it some patterns, and it'll do the heavy lifting for you.
- Rename files using regular expression patterns
- Move files to different locations with optional filtering
- Organize files automatically by type and date
- Support for recursive operations
- Dry run mode to preview changes before applying
- Go 1.21 or higher
- macOS, Linux, or Windows
-
Install Go (on macOS):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew update brew install go -
Clone the repository:
git clone https://github.com/hidayatabisena/filemanager-golang.git cd filemanager -
Build and install:
make install
You can use the file manager in two ways: directly with command-line arguments or through an interactive mode script.
For a more user-friendly experience, use the included helper script:
chmod +x filemanager.sh # first time only
./filemanager.shThe script will guide you through:
- Selecting an operation (rename, move, organize)
- Entering required parameters
- Setting recursive and dry-run options
- Previewing and confirming changes
Rename files based on regular expression patterns:
filemanager -op rename -src ./photos -pattern 'IMG_(\d+)' -replace 'Photo_$1' -recursiveIf your images have file extensions (like image1.jpg, image2.png), you might want to adjust the pattern:
filemanager -op rename -src ./sample -pattern 'image(\d+)(\..+)' -replace 'photo_$1$2'Move files from one location to another, optionally filtering by pattern:
filemanager -op move -src ./downloads -dest ./documents -pattern '\.pdf$' -recursiveAutomatically organize files by type and date:
filemanager -op organize -src ./messy_folder -recursivePreview changes without actually performing them:
filemanager -op rename -src ./photos -pattern 'IMG_(\d+)' -replace 'Photo_$1' -dry-run-op: Operation type (rename, move, organize)-src: Source directory or file pattern-dest: Destination directory (for move operation)-pattern: Regular expression pattern to match files-replace: Replacement pattern for rename operation-recursive: Process directories recursively-dry-run: Show what would be done without actually doing it
This project is licensed under the MIT License - see the LICENSE file for details.
