Friday, 7 October 2016

Ugly!

A dirty one liner as a small reminder for myself. Oh well, it did help my client to get those images out of this rotten old CMS quickly. And it wasn't as dirty as what people in #bash suggested. Dirty? Not dirty at all!

find ./ -iname "*image_large" -print0 | xargs -0 bash -c 'for image; do mv "$image" "$(dirname "$(dirname "$image")")"/$RANDOM.jpg; done' bash

2 comments:

Paul Cobbaut said...

Why is there a 'bash' at the end ?

Mark Van den Borre said...

Paul, https://en.wikipedia.org/wiki/Xargs#Shell_trick .