Start with a folder you can afford to change
Gemini CLI brings an AI assistant into your terminal. For everyday file chores, its most useful role is translating a plain-English request into a command you can inspect. You describe the result; it proposes the shell syntax. That does not make every proposed command safe to run.
For this first lap, use a disposable folder containing copies of a few files. Our example task is turning names such as Trip Photo 01.JPG into trip_photo_01.jpg. The goal is lowercase letters and underscores instead of spaces, without changing file contents.
These examples assume macOS or Linux with a POSIX-style shell. Tell Gemini CLI your actual operating system and shell: commands written for Bash do not automatically work in PowerShell.
Install Gemini CLI and check your starting point
With a supported Node.js version installed, the standard npm installation command is:
npm install -g @google/gemini-cli
Run gemini and complete the authentication flow appropriate to your setup. Before requesting file operations, run pwd to confirm your current folder and ls to inspect its contents. A correct command launched from the wrong directory is still a mistake.
If you want pay-as-you-go model access, SwiftRelay is an option for Gemini CLI, with per-token billing. Sign up for SwiftRelay to try it with the small gift credit available to new accounts. Follow its current Gemini CLI configuration instructions and use the bare API host https://api.fastapirelay.com, without adding /v1. Check model availability and authentication settings rather than assuming an existing Google login configures the relay.
Ask for a read-only shell one-liner first
A shell one-liner is simply a command that fits on one line. Start with a listing task, not a rename. In Gemini CLI, enter this request:
Give me a read-only shell one-liner for macOS or Linux that lists regular files ending in .txt in the current directory only. Do not execute commands or modify files. Explain each part.
A suitable answer might be:
find . -maxdepth 1 -type f -name '*.txt' -print
The dot means the current directory. The depth limit excludes nested folders. The file-type filter selects regular files, and the quoted pattern prevents the shell from expanding it before find receives it. The name match is case-sensitive, so REPORT.TXT is excluded. Matching hidden files can still appear.
This exercise establishes a useful habit: ask for the command, its scope, and its explanation before giving permission to act. Review tool approval requests too; prompt wording is not a substitute for permission controls.
Turn the rename request into an exact specification
“Clean up my filenames” leaves too much room for interpretation. Give Gemini CLI rules it can check:
Draft a Python 3 helper for macOS or Linux that renames files in the current directory only. Lowercase filenames and replace ordinary spaces with underscores. Skip directories, symbolic links, and names beginning with a dot. Default to a dry run showing every old and proposed name. Do not execute anything. Require an explicit --apply flag for changes. Refuse the entire operation if any destination exists or multiple files would get the same destination. Ignore unchanged names when checking conflicts. Explain the script.
A small helper is often clearer than a clever shell one-liner for bulk renames. Python can handle filenames as strings without relying on fragile splitting of command output.
Review the preview before allowing changes
Your dry run should show mappings such as Trip Photo 01.JPG → trip_photo_01.jpg. Check every proposed destination, especially extensions and punctuation. Replacing spaces does not remove other unusual characters.
- Test collisions: Trip Photo.JPG and trip_photo.jpg must not silently overwrite each other.
- Test awkward names: Include spaces, apostrophes, and a leading hyphen in your sample files.
- Check scope: Nested folders, hidden files, and symbolic links should remain untouched.
- Keep recovery material: Preserve original copies and save the old-to-new mapping.
Apply only after the practice run matches
Run the reviewed helper in preview mode yourself, then use its explicit apply option only when the output matches your intent. Avoid editing the folder between preview and application. Destination checks reduce risk, but they do not guarantee protection against concurrent changes or partial failures.
Finally, inspect the resulting names and open a few files. The repeatable workflow is simple: describe narrowly, inspect the command, preview the changes, and apply deliberately. Gemini CLI helps draft the work; you keep control of the filesystem.