mv xrags and cp
Florian Diesch
diesch at spamfence.net
Fri Jan 19 20:48:00 UTC 2007
"OOzy Pal" <oozypal at gmail.com> wrote:
> On 1/19/07, Florian Diesch <diesch at spamfence.net> wrote:
>> John Dangler <jdangler at atlantic.net> wrote:
>>
>> >>
>> >> This command is good
>> >> find olddir -name '*.jpg' -exec cp {} newdir/ \;
>> >>
>> >> how can I make the above command rename the file in the format of
>> >>
>> >> date +%s%N.jpg
>> >>
>> >> to make sure that each file gets a unique name?
>> >>
>> > write a shell script around the command like...
>> > for word in `find olddir -name '*.jpg'
>> > do
>> > ... copy command
>> > done
>>
>> This will fail if there are filenames containing whitespaces.
>>
> Thank you, no whitespaces. But what if there is? Is there a solution.
See my answer to the same mail.
If you want do it with a loop use a while loop:
find olddir -name '*.jpg | while read fname; do
do_something_with_file $fname
done
This works as long as there's no linebreak in a filename
Florian
--
<http://www.florian-diesch.de/>
More information about the ubuntu-users
mailing list