Rename gives "Not a directory"


#1

Trying to rename a file using wildcard, but I get an error message.

  cp *.mp4 new.mp4
  cp: target 'new.mp4' is not a directory

#2

Your use of *.mp4 must be selecting more than one file.

cp will copy multiple files if you give it more than two arguments: it take all but the last filenames as the ones to copy and the last one must then be a directory to copy them to.

(The cp man page’s second “synopsis” line is

       cp [OPTION]... SOURCE... DIRECTORY

SOURCE... means one or more source.)


#3

I only had one mp4 file.

I thought cp let you rename files. Guess not.

This worked.

  mv *.mp4 new.mp4