1

So thanks to this site I've found the way to move all files from current date created on this date to another directory but there is an error which I don't understand:

Thu Aug 31; 15:05:02; marton;~/Свалени ;  $  find . -newermt 20170829 -not -newermt 20180101 -print0 | xargs -0 mv -t /backup/desktop/books/Python/ML-demos/
mv: inter-device move failed: ‘.’ to ‘/backup/desktop/books/Python/ML-demos/.’; unable to remove target: Invalid argument
Thu Aug 31; 15:06:19; marton;~/Свалени ;  $  

Is this problematic and how can I workaround this error ?

2

Your error occurs because your find command finds ., the current working directory, and passes it to mv.

If you're just moving files (not directories), add -type f to the find command:

find . -type f ...(as before)...

This will filter out directories, including the . directory.

You may also get rid of xargs completely:

find . -type f -newermt 20170829 -not -newermt 20180101 \
    -exec mv -t /backup/desktop/books/Python/ML-demos/ {} +
2

You try to move ., which is the current directory. You can remove that by adding -mindepth to your find command. Try it first without piping to xargs, to see if you get the desired result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.