SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
So here's a little rockbox synchronization script that I have come up with:
Code:
#!/bin/bash
# Copyright (c) 2008 alkos333 <me@alkos333.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOURCE="/home/me/media/music/"
DESTINATION="/mnt/ipod/music"
# Synchronizing just the music files (mp3 and ogg in my case)
rsync -vrptgou --delete --force --modify-window=1 --exclude="cover.*" "$SOURCE" "$DESTINATION"
# Find all covers and run a conversion function on them
find "$SOURCE" -type f -name cover.jpg -print0 | while read -d $'\0' jpg_cover
do
echo "Checking $jpg_cover"
# Convert jpeg cover path to bmp path
bmp_cover=${jpg_cover##$SOURCE}
bmp_cover=${bmp_cover%.*}
bmp_cover="$DESTINATION/$bmp_cover.bmp"
# Check if bmp cover exists and if it's up-to-date
if [ ! -f "$bmp_cover" ] || \
[ \( $( stat --printf=%Y "$jpg_cover" ) -gt $( stat --printf=%Y "$bmp_cover" ) \) ]
then
# Convert to 100x100 bmp cover if either condition fails
convert "$jpg_cover" -resize 100x100 "$bmp_cover"
echo " --> Converting and saving to $bmp_cover"
fi
done
For some reason rsync complains that it can't delete non-empty directories despite the fact that there is a recursive flag, --delete and --force supplied as well.
If I change the --exclude to "cover.jpg" since all covers are in jpg on my laptop, then it's not complaining. Looks like all of bmp covers which are present on my ipod are ignored thoughout despite delete and force flags. How do I around this?
Well it removes the files alright if I don't user the --exclude flag with "cover.*"
Here's what the problem is. I tell rsync to exclude the cover.* files because I take care of them afterward. However, when rsync wants to remove certain directory which no longer exist in SOURCE (due to --delete flag), it can't because they contain cover.bmp in them which are covered by the --exclude pattern.
Basically, I want rsync to leave cover.bmp files alone, but if it's removing a directory that no longer exist in the source directory, I want it removed along with cover.bmp even though it's supposed to be excluded. I thought --force would get that done, but apparently it isn't working :/
It's weird as I've never had this issue before, it just started today. Doing this over a sshfs connection that is connecting to a mount.cifs mount on a remote server. (can't do mount.cifs directly as there is a NAT)
--delete-excluded removes all of cover.bmp files and I want those excluded unless the folder they are in is being removed entirely because let's say that album/artist has been removed from my source directory
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
Advertisement
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Click Here to receive a complimentary subscription courtesy of LQ.