# Zsh: manipulate filenames with modifiers like :r (root) and :e (extension)

DevFeed: [Zsh: manipulate filenames with modifiers like :r (root) and :e (extension)](<https://devfeed.tech/articles/zsh-manipulate-filenames-with-modifiers-like-r-root-and-e-extension-51101.md>)

Original publisher: [Read original article](<https://adamj.eu/tech/2026/08/24/zsh-filename-modifiers/>)

Author: Adam Johnson

Published: 2026-08-23T23:00:00Z

Content type: tutorial

Language: en

Sources: [Adam Johnson](<https://devfeed.tech/sources/adam-johnson.md>)

Topics: [Zsh](<https://devfeed.tech/topics/zsh.md>), [Code](<https://devfeed.tech/topics/code.md>), [Bash](<https://devfeed.tech/topics/bash.md>), [ImageMagick](<https://devfeed.tech/topics/imagemagick.md>)

Tags: [bash](<https://devfeed.tech/tags/bash.md>), [build](<https://devfeed.tech/tags/build.md>), [command](<https://devfeed.tech/tags/command.md>), [files](<https://devfeed.tech/tags/files.md>), [imagemagick](<https://devfeed.tech/tags/imagemagick.md>), [images](<https://devfeed.tech/tags/images.md>), [loops](<https://devfeed.tech/tags/loops.md>), [variable](<https://devfeed.tech/tags/variable.md>), [variables](<https://devfeed.tech/tags/variables.md>), [zsh](<https://devfeed.tech/tags/zsh.md>)

## AI overview

A tutorial on using Zsh filename modifiers such as :r for removing extensions and :e for extracting them, including chaining modifiers and applying them in a loop that converts PNG images to WebP with ImageMagick.

## Source excerpt

Zsh modifiers are a family of suffixes that transform words as they're expanded. Several of them are dedicated to slicing up filenames, replacing fiddly calls to dirname, basename, and friends. Let's take a look at them now! The filename modifiers Four modifiers cover most filename manipulation. Take this ...