My photo importer moved files from my camera and renamed them, but I forgot to specify that it should keep the file extension. So I have several folders with hundreds of JPG & AVI files that are all missing their proper extension.
There aren't that many video files so I can manually rename them either before of after a general mass-rename to JPG.
To make things more complicated, the filenames contain spaces, so I can't just mv "*" "*.jpg"
because, well, that doesn't work (but that's what I'd do, coming from DOS/Windows).
I know Linux is full of powerful commands. How can I mass-rename files to add a .jpg extension, when those files contain spaces?
Please don't say "don't use spaces" because that's really not what I'm asking about. Thanks.
find /PATH/TO/FOLDER -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;
(source) which will replace all spaces in files & folders & subfolders for you.