Although the answer from the original author is correct, I think it is better to explain why the mv
command listed in the question does not work.
The problem is a basic misunderstanding on the way in which a Unix shell works --- which is quite different form DOS command line. The special characters (*, ?, etc.) which select multiple files (they are called 'glob') works at the level of the shell, not of the commands. So the first command is expanded by the shell to
mv x54y56.dat x57y58.dat x59y60.dat "some prefix - *"
I am supposing that in the directory you have just this three files for sake of simplicity, and that you have no file which matches the name of "some prefix - "
pattern --- so that the shell will probably let it as is. (I am using the quotes to embed spaces, I find it more easily readable than backlashes, although the fine details are in the manual for your shell).
Now, mv a b c d
will try to move the files a
, b
, c
to the directory d
, and failing --- because d
does not exist.
The rename
solution, if you have the rename
command, is the Right One. As the OP found,
rename 's//some prefix - /' *.dat
works ok. In the old good days, you where supposed to do
for i in *.dat; do
mv "$i" "some prefix - $i"
done
to just do one move at time.
rename 's//some prefix - /' *.dat
Found the help here: link