Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Location
    Catalonia
    Posts
    35

    Question Mass file rename (strip leading dot and random end string) rsync error


    Hello!

    It seems that there is a bug in rsync when copying to some filesystems, by which the rename operation fails randomly when performing backup. The task is unable to rename a temp file created during backup and ends with an error (but the files are copied entirely and correctly). It happens when copying to an LTFS (linear tape filesystem), a high capacity magnetic tape, and I read that also happens within other filesystems and/or devices:

    Code:
    rsync: rename "/mnt/ltfs/file.ext" -> "file.ext": Operation not permitted (1)
    The bug is not corrected in rsync version 2.6.9 protocol version 29 (under OS X Mountain Lion, xnu-2050.48.12~1/RELEASE_X86_64).

    So some copied files end up with a leading dot (so, hidden) and a six character random trailing string:

    Code:
    .file.ext.abcde
    I don't think if there's a solution within rsync, so I need to mass rename the few copied files that end up with the dot and the trailing string (recover the original filename):

    Code:
    .file.ext.abcde -> file.ext
    The filename contains no spaces and the trailing string varies.

    In OS X there's no rename command (I can't install anything). Maybe sed, awk? (sorry but I have not enough experience with these commands).

    Any help will be appreciated!

    Salut!

  2. #2

  3. #3
    What about something like this:


    for fn in *
    do
    char1=${fn:0:1}
    if [ $char1 != "." ]
    then
    continue
    fi
    prefix=$(cut -d'.' -f 2)
    suffix=$(cut -d'.' -f 3)
    mv $fn $prefix"."$suffix
    done
    Last edited by BowCatShot; 08-08-2014 at 07:23 PM.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •