Quote:
Originally Posted by Chekote
I'm trying to search a volume for all JPEG files without a jpeg extension, and add it.
I found a lot of similar questions, which were a great deal of help, but I've ran into a problem with my command.
This is what I have so far:
Code:
find . -type f -exec file {} \; | grep JPEG | grep -vi ".jpg" | cut -d ":" -f1 | xargs -0 -t -I "{}" mv {} {}.jpg
Everything works fine up to the xargs, at which point I end up with the following error:
Code:
mv: rename {} to {}.jpg: No such file or directory
Obviously I'm not populating the {} parameter correctly, even though this command works fine without the "find" at the beginning:
Code:
file * | grep JPEG | grep -vi ".jpg" | cut -d ":" -f1 | xargs -t -I "{}" mv {} {}.jpg
I almost had this working without having to post another thread. v_v
Thanks in advance for the help.
|
Quote:
I'm trying to search a volume for all JPEG files without a jpeg extension, and add it.
|
In computer science you need to spell things out. Tell us what extensions the files do have. The only way to unambiguously rename the files is if we know what name they have now.
For example, if you have a bunch of files that had [filename].JPEG as a name, and you wanted them to be renamed [filename].jpg, you would do this:
Code:
path="/path/of/interest"
find $path -type f | grep -P "\.JPEG$" | while read oldpath
do
newpath=${oldpath//.JPEG}.jpg
echo "testing: mv $oldpath $newpath"
# mv $oldpath $newpath
done
(After testing and satisfying yourself that the script works, uncomment the commented line "mv $oldpath $newpath".)
But remember to think very clearly about the problem to be solved. That way you don't run a bunch of pointless code, solving nonexistent problems.
And whatever you do,
avoid the use of "xargs" in any context whatsoever. The longest, most pointless threads in this discussion board revolve around attempts to use "xargs", and they frequently result in the original poster either being led away by men in white coats, or leaping off a cliff.
I cannot confirm the rumor that "xargs" was written by Bill Gates in order to undermine the entire Linux establishment, but based on the content of these discussion boards,
it's working.
Quote:
Everything works fine up to the xargs ...
|
Famous last words.