this post was submitted on 24 Apr 2025
196 points (97.1% liked)

Comic Strips

16181 readers
1399 users here now

Comic Strips is a community for those who love comic stories.

The rules are simple:

Web of links

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] jordanlund@lemmy.world 3 points 2 days ago (2 children)
[–] WrenFeathers@lemmy.world 2 points 2 days ago

Ahh. Makes sense that it can be automated. Same as with audio engineering. Though I like to normalize by hand sometimes as automated normalization tends to make a track sound lifeless and dead.

[–] tal@lemmy.today 1 points 2 days ago

A Perl program to convert the number of digits in the first numeric field that appears in a list of filenames.

source

#!/usr/bin/perl -w
# numberit.pl
# Converts between number formats (number of leading zeros) in numbers in title names
# Usage: <number of digits> filelist

$digits = shift (@ARGV);

if ($digits > -1)
{
    foreach $oldName (@ARGV)
    {
        $newName = $digitValue = $oldName;

        if ($digitValue =~ m/\//) {
          $digitValue =~ m/^(.*\/[^0-9\/]*)([0-9]+)([^\/]*)$/;
          $prefix = $1;
          $postfix = $3;
          if (!defined($prefix)) {
            $prefix = "";
          }

          $digitFormatted = sprintf("%0${digits}d", $2);

        } else {
          $digitValue =~ m/^([^0-9]*)([0-9]+)([^\/]*)$/;
          $prefix = $1;
          $postfix = $3;
          if (!defined($prefix)) {
            $prefix = "";
          }

          $digitFormatted = sprintf("%0${digits}d", $2);


        }

        if ($digitValue) {
          $newName = $prefix . $digitFormatted . $postfix;
          rename($oldName, $newName);
        }
      }
}

Looks something like:

$ touch a1.mp3
$ touch a2.mp3
$ numberit.pl 3 *
$ ls
a001.mp3  a002.mp3
$ numberit.pl 2 *
$ ls
a01.mp3  a02.mp3
$