Amazon S3 has no native "rename" operation, but the AWS CLI's aws s3 mv command gets you there in one line. I'll walk through building the command, reusing it efficiently, and verifying the result — along with a caveat about what mv is really doing under the hood.
The problem: S3 doesn't really do renaming
If you're coming from a local filesystem background, renaming a file feels like a non-event. You right-click, type a new name, and you're done. S3 doesn't work that way. Objects in a bucket are identified by their key, and there's no underlying "rename" primitive the way there is on a local disk or even most traditional file servers. Every rename you do in S3 is actually a workaround.
That's not a huge deal in practice, but it's worth internalizing before you start scripting around it, because it changes how you should think about the operation. I ran into this recently while cleaning up a photos prefix in one of my buckets — I had a file called example.png that needed to become example2.png, and I wanted a clean, repeatable way to do it from the command line rather than fumbling through the console.
The tool for this is the AWS CLI, specifically the aws s3 mv subcommand. It's built to feel familiar if you've used mv on Linux or macOS, and for a single object like this, it does the job in one command. The syntax mirrors what you'd expect: source first, destination second. But — and this is the part I want to flag early rather than bury at the end — it's not literally the same operation as a local move, even though it's designed to feel like one. More on that shortly.
Building the aws s3 mv command
The basic shape of the command is straightforward:
aws s3 mv s3://your-bucket/photos/example.png s3://your-bucket/photos/example2.png
The first argument is the object you're moving (or in this case, renaming), and the second is where you want it to end up. Since I was keeping the file in the same prefix and just changing the filename, both paths were nearly identical — only the last segment differed.
One small thing worth calling out if you're following along by ear rather than reading documentation: when people talk through this command out loud, they'll often say "AWS S3 move." That's just a verbal shorthand for the mv subcommand — it's not a literal word you type. If you're transcribing a command from a video or a lesson, make sure you're typing mv, not move. It's an easy typo to make if you're going off what you heard rather than what you saw on screen.
Because the full path — bucket name, prefix, and filename — can get long, retyping it for both the source and destination is tedious and error-prone. What I actually did was type the source path once, then copy the whole command and paste it again, editing only the destination filename. That gave me two nearly identical commands stacked in my terminal history, with just the last few characters different. It's a small habit, but it cuts down on typos significantly, especially when your bucket structure has multiple nested prefixes and the paths get unwieldy.
Once the command was ready, running it took a beat, and then the prompt returned with no output — which, in CLI land, usually means success. But I don't love trusting "no news is good news" for something like a rename, so the next step was confirming it actually happened.
Verifying the rename actually worked
The AWS CLI is generally quiet when things go right, which is convenient for scripting but not always reassuring when you're doing something manually. So after running the mv command, I wanted to see the updated object listing before moving on.
Rather than typing out the aws s3 ls command again from scratch, I used my shell's command history — hitting the up arrow to cycle back to a listing command I'd run earlier in the session. That's a small efficiency habit worth building if you don't already have it: most shells will let you cycle through recent commands, search history with something like Ctrl+R, or re-run the last command outright. When you're working through a bunch of similar CLI operations in sequence, leaning on history saves a surprising amount of time and typing.
The recalled command pointed at the photos prefix:
aws s3 ls s3://your-bucket/photos/
Running it listed out the objects under that prefix, and there it was — example2.png sitting in the listing, with example.png no longer present. That's the confirmation I was after: the object had effectively been renamed, at least from the outside looking in.
This two-step pattern — perform the operation, then re-list to confirm — is a habit I'd recommend keeping regardless of how confident you are in the command. S3 operations don't have an undo button, and a quick listing check costs you almost nothing.
What's actually happening under the hood
Here's the part that's easy to gloss over because the command feels just like a local move: S3 doesn't support true in-place renames. There's no metadata flag that just relabels an object. Instead, aws s3 mv works by copying the object to the new key and then deleting the original. From the CLI's perspective, and from yours as the person running the command, it looks like a single atomic move. Under the hood, it's two separate operations chained together.
For a small image file like the one I was working with, this distinction is mostly academic — the copy-then-delete happens fast enough that you'd never notice. But it's worth keeping in the back of your mind for a few reasons. First, if you're renaming very large objects, you're effectively paying for a full copy operation, not a cheap pointer update, which can matter for both time and cost at scale. Second, because it's two discrete API calls rather than one atomic filesystem operation, there are edge cases around timing and reliability that behave differently than a true move would — the specifics can depend on object size, versioning settings, and other bucket configuration, so I'd treat this as something to test for your own use case rather than assume it behaves identically to a local mv in every scenario.
None of this means you should avoid aws s3 mv — it's still the right tool for renaming or relocating objects from the command line, and for typical use it just works. It's more that the naming ("move") is doing some marketing work: it makes an operation that's really "copy, then confirm, then delete" feel as simple and atomic as dragging a file on your desktop. Understanding that gap helps you reason correctly about cost and behavior when you're working with more than a handful of small files.
A few habits worth carrying forward
Beyond the specific command, there were a couple of workflow habits from this exercise that I think are worth keeping regardless of what CLI tool you're using. Reusing a command by copying it and editing just the part that changes is a small thing, but it meaningfully reduces typos on long, path-heavy commands — and S3 paths get long fast once you're several prefixes deep. Leaning on shell history instead of retyping commands you just ran is another one; it's a tiny efficiency gain per command, but it compounds over a session full of similar operations.
The bigger habit, though, is the verify-after-you-act pattern. Renaming a file locally is trivially reversible — you can just rename it back if something goes wrong. Renaming in S3 involves a copy and a delete, and if something goes sideways partway through (a permissions issue, a network hiccup, a typo in the destination path), you want to know immediately rather than discovering it later when something downstream expects the old key to still exist. A quick aws s3 ls after any structural change to a bucket is cheap insurance.
Conclusion
If you've got a file sitting in an S3 bucket with the wrong name, the fix is a single aws s3 mv command away — just remember it's a copy-and-delete wearing a move's clothing, so it's worth a quick listing check afterward to confirm the result. Try it on a low-stakes object in one of your own buckets to get a feel for the syntax before you rely on it for anything larger.
Official AWS references
KEEP PRACTICING THE DECISION
Learn the concept, then test the edge case.
The Solutions Architect Associate course in TutorialRepo combines guided lessons, scenario questions, review, and course-aware explanations.