From d65f513592af8fb84be1393ff0867531604ade3d Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 1 May 2008 06:51:04 +0000 Subject: [PATCH] =?utf8?q?Kleine=20=C3=84nderungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- convert-sicher-filename.pl | 17 +++++ convert-sicher-filename.sh | 17 +++++ sicher.sh | 137 ------------------------------------- 3 files changed, 34 insertions(+), 137 deletions(-) create mode 100755 convert-sicher-filename.pl create mode 100755 convert-sicher-filename.sh delete mode 100755 sicher.sh diff --git a/convert-sicher-filename.pl b/convert-sicher-filename.pl new file mode 100755 index 0000000..7287e40 --- /dev/null +++ b/convert-sicher-filename.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +for my $fname_old ( @ARGV ) { + + my ( $base, $day, $time, $ext ); + if ( ( $base, $day, $time, $ext ) = $fname_old =~ /^(.*)\.(\d\d\d\d-\d\d-\d\d)[\-_](\d\d-\d\d-\d\d)(\..*)?$/ ) { + $ext ||= ''; + print $base . $ext . '.' . $day . '_' . $time . "\n"; + } + else { + print $fname_old . "\n"; + } + +} diff --git a/convert-sicher-filename.sh b/convert-sicher-filename.sh new file mode 100755 index 0000000..a44d9ab --- /dev/null +++ b/convert-sicher-filename.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +PL_SCRIPT="/usr/local/scripts/convert-sicher-filename.pl" + +if [ ! -x "$PL_SCRIPT" ] ; then + echo "'$PL_SCRIPT' nicht gefunden." >&2 + exit 99 +fi + +for f in *; do + n=`"$PL_SCRIPT" "$f"` + if [ "$f" != "$n" ] ; then + printf "mv '%s' -> '%s'\n" "$f" "$n" + mv -i "$f" "$n" + fi +done + diff --git a/sicher.sh b/sicher.sh deleted file mode 100755 index 159d826..0000000 --- a/sicher.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/sh - -# $Id$ -# $URL$ - -# set -x - -if [ -x /usr/local/bin/date ] ; then - DATE=/usr/local/bin/date -elif [ -x /usr/local/gnu-bin/date ] ; then - DATE=/usr/local/gnu-bin/date -else - echo "GNU-Date nicht gefunden!" >&2 - exit 10; -fi - -OIHF="$IFH" -IFH=" -" - -#set -x - -if [ "$#" = "0" ] ; then - echo "Keine Dateien angegeben, verwende statt dessen '.'." - #FILES="." - set "." -#else - #FILES=$@ -fi - -if [ "${OLD_DIR}" = "" ] ; then - OLD_DIR=".old" -fi - -#--------------------------------------------- - -perform_file() { - - F="$1" - - if [ ! -f "$F" ] ; then - return - fi - FILEDIR=`dirname "$F"` - FOLDDIR="${FILEDIR}/${OLD_DIR}" - - if [ ! -d "${FOLDDIR}" ] ; then - echo "Erstelle Verzeichnis '${FOLDDIR}' ..." - mkdir "${FOLDDIR}" || exit 2 - fi - - n="${FOLDDIR}/`basename ${F}`.`$DATE -r \"${F}\" '+%Y-%m-%d_%H-%M-%S'`" - echo " - '${F}' -> '$n'" - cp -p "${F}" "${n}" - -} - -#--------------------------------------------- - -perform_dir() { - - D="$1" - - echo "Sichere Verzeichnis '${D}' ..." - # sleep 1 - - for NODE in `ls -1 -d "${D}"/* "${D}"/.* 2>/dev/null` ; do - - # echo "Untersuche Node '${NODE}' ..." - BASENAME=`basename "${NODE}"` - # echo "Basename: '${BASENAME}'" - # sleep 1 - - SKIP=0 - - if [ "${BASENAME}" = "." ] ; then - SKIP=1 - fi - - if [ "${BASENAME}" = ".." ] ; then - SKIP=1 - fi - - if [ "${BASENAME}" = "${OLD_DIR}" ] ; then - SKIP=1 - fi - - if [ -L "${NODE}" ] ; then - SKIP=1 - fi - - if [ "${SKIP}" = "0" ] ; then - - if [ -d "${NODE}" ] ; then - perform_dir "${NODE}" - elif [ -f "${NODE}" ] ; then - perform_file "${NODE}" - fi - - fi - - done - -} - -#--------------------------------------------- - -perform_node() { - - N="$1" - - if [ -L "$N" ] ; then - return - fi - - if [ -d "$N" ] ; then - perform_dir "$N" - return - fi - - if [ -f "$N" ] ; then - perform_file "$N" - fi - -} - -while [ "$#" != "0" ] ; do - perform_node "$1" - shift -done - -IHF="${OIFH}" - -exit 0 - -#--------------------------------------------- - -- 2.39.5