Bash
mv folder/file1 folder/file2
This is the command to move a file to a different directory. if the same directory is specified, the file is renamed instead.
Java
File file = new File("file1");
file.renameTo(new File("file2"));
Python
Perl
See Also