Kleinschreibung per perl-script

Hier ein perl-script[1], das alle Dateien in einem Ordner (inklusive Unterordner) in Kleinbuchstaben umwandelt:

#!/usr/bin/perl -w
use strict;

# Open 'find' process to list files recursively with paths
open(FIND, "find |");
while() {
        chomp;
        next if $_ eq $0;        # Don't rename ourself
        rename($_, lc($_));
        }
close(FIND);

Einfach mit chmod u+x ausführbar machen und mit ./foo.pl starten.

Es lief auf meinem Debian-Rechner problemlos, allerdings konnte ich es nicht auf meinem OpenBSD-Server starten. Die Ursache war find – im Gegensatz zu Linux muss man unter OpenBSD noch ein Verzeichnis angeben, zB “.” für das aktuelle.
So lief es auf OpenBSD:

#!/usr/bin/perl -w
use strict;

# Open 'find' process to list files recursively with paths
open(FIND, "find . |");
while() {
        chomp;
        next if $_ eq $0;        # Don't rename ourself
        rename($_, lc($_));
        }
close(FIND);

[1] http://webxadmin.free.fr/article/shell-rename-all-files-in-subdirectories-to-lowe-135.php

Comments are closed.