Learning Bash Questions: the MV command
- From: "Dotan Cohen" <dotancohen@xxxxxxxxx>
- Date: Tue, 28 Feb 2006 09:26:01 +0200
I am trying to learn as I go with bash on a FC4 install. I need to do
two things that are confounding me:
1) I need to move all the photos from a huge, complex tree to one big
directory. Easy:
$ find . -name "*.jpg" -exec mv '{}' /home/dotancohen/big_directory \;
However, there are a few photos that have duplicate file names in
different directories. In this case, it overwrites. That is bad! I
tried adding the -i flag to prompt me, but it takes the next 'mv' as a
response to the prompt, and the next 'mv' fails. Is there a way to
have it not fail the next mv, yet not overwrite? Or better yet, in the
case of duplicate file names, to append something to the end of the
file name, so that it will not be duplicate? Of course, if _that_ file
name is taken, it should append something else, etc. Is this too
complex for Bash?
2) I will then be left with a huge tree with mostly empty directories.
I need to remove the empty directories, but leave those in place that
do contain files. Is there a way to check if a directory is populated
before 'rm'ing it? If the directory contains another directory that
_is_ empty, then of course they should both be deleted. Er, is this
possible?
Thank you in advance.
Dotan Cohen
--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
- Follow-Ups:
- Re: Learning Bash Questions: the MV command
- From: Paul Howarth
- Re: Learning Bash Questions: the MV command
- Prev by Date: [FC4] Thunderbird-1.5 rpm?
- Next by Date: Re: How to make programs link the lib64/* instead of lib/* on FC4?
- Previous by thread: [FC4] Thunderbird-1.5 rpm?
- Next by thread: Re: Learning Bash Questions: the MV command
- Index(es):