file-renamer-cli
v1.0.5
Published
A command-line interface tool to automatically rename and organize screenshot files based on timestamps and JIRA IDs.
Downloads
494
Readme
file-renamer-cli
A command-line interface tool to automatically rename and organize screenshot files based on timestamps and JIRA IDs.
Features
- Automatically renames screenshot files using JIRA IDs and timestamps
- Groups screenshots into test cases based on configurable time gaps
- Supports dry run mode for previewing changes
- Provides undo functionality for reverting the last renaming operation
- Easy to use with intuitive command-line options
Installation
You can install Screenshot Renamer CLI globally using npm:
npm install -g file-renamer-cli
Usage
Basic Usage
To rename screenshots in a specific directory:
file-renamer-cli -d /path/to/your/screenshots
You will be prompted to enter a JIRA ID (e.g., SSM-123). The tool will then process all PNG files in the directory that match the naming pattern "Screenshot YYYY-MM-DD at HH.MM.SS AM/PM.png".
Command-line Options
-d, --directory <path>
: Specify the directory containing screenshots.-t, --time-gap <minutes>
: Set the time gap (in minutes) to separate test cases. Default is 5 minutes.--dry-run
: Perform a dry run without actually renaming files.--undo
: Undo the last renaming operation.
Examples
- Rename screenshots with a custom time gap:
file-renamer-cli -d /path/to/screenshots -t 10
This sets the time gap to 10 minutes. Screenshots taken more than 10 minutes apart will be considered part of different test cases.
- Perform a dry run:
file-renamer-cli -d /path/to/screenshots --dry-run
This will show you how files would be renamed without making any changes.
- Undo the last renaming operation:
file-renamer-cli --undo
File Naming Convention
The tool expects screenshot files to follow this naming convention:
Screenshot YYYY-MM-DD at HH.MM.SS AM/PM.png
For example: "Screenshot 2024-09-22 at 2.31.16 AM.png"
Only files matching this pattern will be processed.
Output
- Renamed Files: The tool will rename your files to the format
[JIRA-ID]-tc-[TestCaseNumber]-[ScreenshotNumber].png
. - Console Output: The tool will print information about each renaming operation.
- Log File: A
rename_log.json
file is created in the working directory, recording all renaming operations.
Best Practices
- Always run with
--dry-run
first to verify the expected changes. - Use descriptive JIRA IDs to easily identify the associated task or bug.
- Regularly back up your screenshots before running the tool.
- Use the
-t
option to adjust the time gap based on your testing workflow.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any problems or have any questions, please open an issue in the GitHub repository.
Acknowledgments
- Thanks to all contributors who have helped shape this tool.
- Inspired by the need for efficient screenshot management in software testing workflows.