Showing posts with label regex. Show all posts
Showing posts with label regex. Show all posts

2021-10-16

ZMV ON WINDOWS!?? [NOT CLICKBAIT]

    Hello netizens. I use Windows now, which means I have to use PowerShell. It's actually pretty neat once you get past the bizarre Verb-Noun command format.

    But, this means I can't use such great features as zmv, which I wrote about in a previous blog post. (I spent five minutes thinking of funny ways to ridicule the fact that I'm not linking to that blog post here but couldn't think of anything worthwhile.)

    Or can I? Well, duh, of course I can. zmv is just a funky little function. I can make my own damn functions on Windows.

    Let's use my previous example of renaming "Artist name - Album title - Track # Track name.flac" to "Artist/Album/# Track.flac" — SHIT, I mean "Artist\Album\# Track.flac". Sorry Gates.

    BEHOLD: zmv for Windows.

Get-ChildItem . | Rename-Item -NewName { $_.Name -replace '^(.*) - (.*) - (.*)','$1\$2\$3' }

    It's a bit more complicated, sure, but it works. Thanks, StackOverflow!

    (Really this series of blog posts is just me learning regex but that doesn't mean I can't look cool while doing it.)



    P.S. While figuring out how to pick PowerShell's background color, I learned that Microsoft PowerToys has a tool for doing regex renames with a fancy GUI, called PowerRename. Freakin awesome!!


    Only problem is that it's not integrated with Windows 11's new context menu (yet?)

2020-08-24

`zmv` Is Awesome

    BEHOLD! I have awaken from my year-long slumber to grace ye feeble peasants with glorious and other such wondrous things.

    Today, I'd like to shed light on a rather interesting little program: `zmv`. Included with the Z shell, or "zsh", `zmv` allows the user to move files and folders neatly about by following simple-to-use patterns. For example, let's say I've just downloaded an album off of LimeWire with its files in the format of "Artist name - Album title - Track # Track name.flac". It would be rather time-consuming to individually rename each and every file to the desired format of "Artist/Album/# Track.flac", no?

    With `zmv`, I simply need to run `zmv '(*) - (*) - (*)' '$1/$2/$3'`, and shabam-a-lama! My files have moved to perfectly organized directories and subdirectories. How wonderful! How superb!

    And with that, I'm off again. See you all in 2021, I suppose.