[Tutor] Move all files to top-level directory

Dotan Cohen dotancohen at gmail.com
Tue Apr 13 10:39:09 CEST 2010

> I would add a few different features to this 'find' to make it a bit
> more resistant to failure, although this sort of solution is always
> subject to the "somebody else is toying with my filesystem race
> condition".
>  find "$srcdir" -depth -type f -print0 \
>    | xargs --null --no-run-if-empty -- \
>      mv --target-directory "$dstdir" --
> The --target-directory option is only available in GNU mv (and cp),
> I believe.

I am trying to get into Python now, but I will go over that at a later
time to improve my shell scripting skills. Thanks. I do appreciate the

> I'll second the recommendation for 'shutil', although you can have
> some fun playing with recursion by building your tree flattener
> using os.walk(), os.path.split() and os.path.join().

For certain values of "fun"! Actually, I did enjoy this exercise. I
learned a lot, and found some great resources. Python really is a fun

Dotan Cohen


More information about the Tutor mailing list