cogset
February 25th, 2015, 08:44 PM
I apologize if this isn't so much of a programming question but rather a general question about using find and xargs, if this needs to be moved please do so.
Having said that, I'm after a combination of commands that will allow me to find all *jpeg files in a directory, rename them to *jpeg and then immediately link those renamed files in another directory where I keep an index of recent files.
So far I've come up with this
find . -mindepth 1 -exec rename 's/\.jpeg$/\.jpg/' '{}' ';'which works, what I'd like to do next is to link the resulting *jpg files to another directory using one command.
To that extent I've tried
find . -mindepth 1 -exec rename 's/\.jpeg$/\.jpg/' '{}' '; |xargs -I {} cp -s {} /tmp but to no avail, I really don't know this stuff and xargs in particular, so is there any way to make this work?
Should I use something else altogether?
I've also tried this
find . -mindepth 1 -exec rename 's/\.jpg$/\.jpeg/' '{}' ';' && for F in '*jpeg' ; do find $F -cmin -1 -exec cp -s '{}' /tmp/ ';' ; done but it doesn't work either, refusing to create the links.
Having said that, I'm after a combination of commands that will allow me to find all *jpeg files in a directory, rename them to *jpeg and then immediately link those renamed files in another directory where I keep an index of recent files.
So far I've come up with this
find . -mindepth 1 -exec rename 's/\.jpeg$/\.jpg/' '{}' ';'which works, what I'd like to do next is to link the resulting *jpg files to another directory using one command.
To that extent I've tried
find . -mindepth 1 -exec rename 's/\.jpeg$/\.jpg/' '{}' '; |xargs -I {} cp -s {} /tmp but to no avail, I really don't know this stuff and xargs in particular, so is there any way to make this work?
Should I use something else altogether?
I've also tried this
find . -mindepth 1 -exec rename 's/\.jpg$/\.jpeg/' '{}' ';' && for F in '*jpeg' ; do find $F -cmin -1 -exec cp -s '{}' /tmp/ ';' ; done but it doesn't work either, refusing to create the links.