Search code examples
macosterminalfile-rename

add a string to the name of several .pdf file in Terminal in MacOS


Using Terminal in MacOS, what is the command to add a particular string to the name of several .pdf file. E.g.: if I have

firstfile.pdf
anotherfile.pdf
documentthree.pdf

I want them all to be renamed

addedstring_firstfile.pdf
addedstring_anotherfile.pdf
addedstring_documentthree.pdf

Solution

  • Could you please try following(don't have mac os so didn't test on it).

    for file in *.pdf
    do
       mv "$file" "string_$file"
    done