LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Renaming multiple files (https://www.linuxquestions.org/questions/linux-newbie-8/renaming-multiple-files-701529/)

Changes 02-01-2009 09:26 PM

Renaming multiple files
 
I have many files named (number).jpg that I want to rename to (number)_sm.jpg (thumbnails, "sm" is short for "small").

How do I do this via shell? I've tried futzing around with mv, rename and wildcards characters, but it's getting me nowhere.

worldwise001 02-01-2009 09:58 PM

try this:

Code:

for f in *.jpg ; do mv $f ${f%.jpg}_sm.jpg; done


All times are GMT -5. The time now is 03:25 AM.