Hello Bod, 

I am working on a sort of extension to mv:

echo "Enhancement to mv program"
if [ -d "$1"  ] && [ ! -d "$2"  ]  ; then 
        echo "Creating folder $2"       ; mkdir -p "$2" 
fi

if [ -d "$1" ] ; then 
        FOLDER=`basename "$1"`
        var="$2" ; lastchar="${var##${var%%?}}"
        if [ "$lastchar" = "/"  ] ; then 
                TARGET="$2$FOLDER"
                else
                TARGET="$2/$FOLDER"
        fi
        echo "Moving folder $1  to $TARGET"
        [ ! -d "$2"  ] && mkdir -p "$2"
        rsync -avPr --ignore-existing --remove-source-files "$1" "$2"
else
        TARGET="$2"
        echo "Moving file $1 to $TARGET"
        rsync -avPr --ignore-existing --remove-source-files "$1" "$TARGET"
fi

However it is not perfeclty working... since it moves wrongly the content of 
folder or create a newer one.

the right way would be :
movemerge /path/sourcefolder /path2/targetfolder
and one gets:  /path2/targetfolder/sourcefolder

well not working ... yet. I hope I can make it;

best regards
F.






________________________________
From: Bob Proulx <b...@proulx.com>
To: Frenchn00b <frenchn...@yahoo.com>; 605...@bugs.debian.org
Sent: Fri, December 3, 2010 10:50:29 PM
Subject: Re: Bug#605832: /bin/mv: Issue with "mv: inter-device move failed: "

Frenchn00b wrote:
> mv PDF /home/gerard/
> mv: inter-device move failed: `PDF' to `/home/gerard/PDF'; unable to remove 
>target: Is a directory

The target /home/gerard/PDF appears to be a directory.  The source
also appears to be a directory.  You are trying to move a directory on
top of an existing directory.  Plus this is across devices.  The
source and destination directories exist on different filesystems.
That combination is triggering this problem.  But it isn't really a
bug in mv so much as a limitation of what can be done in that case.

In order to do this mv tries to remove the target so that it can be
replaced with the source.  But the target is a directory and therefore
throws this error.  Think about the problem of what mv would need to
do if the target directory contained other files.  Should it remove
those files first?  That could get into a loss of data situation.

In those situations it is better to copy the files from the source
directory into the target directory.  Then remove the source if you
want it to go away.

  $ cp -a PDF /home/gerard/
  $ ..ifdesired... rm -rf PDF

Sometimes people fall into this because they have run a cp command
multiple times back to back.  The first one copies the directory and
then it exists in both places.  Then they try to move the directory
and find that it already exists.  In those cases where one is repeated
copying the contents of a directory from one place to another the
rsync command is most suited to the task.

  rsync -a source destdir/

> I did ls -ltra and visibly there is no LN link file going on ... I
> still do not understand what is about this issue

What does this say?

  $ ls -ld PDF /home/gerard/PDF

That should show it as a directory in both the source and destination.

If the above is not the case then the following are more instructions
for getting further information.  If your problem is solved by the
above then nothing below this is needed.

What are the types of the filesystems involved?  This can be seen with
the 'df -T' option.  The type column will say this information.  I am
wondering if non-unix filesystems such as VFAT are involved?

  $ df -TP . /home/gerard

To get more information it would be useful to trace the system calls
and report what mv is doing.  The strace command is useful for this.

  $ sudo apt-get install strace

Then use it to strace the mv command and report what it is happening
with the system calls like this:

  $ strace -v -o /tmp/mv.strace.out -e trace=file mv PDF /home/gerard/

Thanks,
Bob



      

Reply via email to