Results 1 to 3 of 3

Thread: Linux Rename File Command

  1. #1
    Join Date
    Nov 2009
    Posts
    76,596

    Default Linux Rename File Command

    You need to use the mv command. It is used to rename and move files and directories. The general syntax is as follows:

    Code:
    mv old-file-name  new-file-name
    mv [options] old-file-name  new-file-name
    mv file1 file2
    In this example, the following command would rename a file called resumezzz.pdf to resume.pdf. Open a command-line terminal (select Applications > Accessories > Terminal), and then type:

    Code:
    mv resumezzz.pdf resume.pdf
    If resumezzz.pdf is located in /home/vivek/docs/files directory, type:

    Code:
    cd /home/vivek/docs/files
    mv resumezzz.pdf resume.pdf
    OR

    Code:
    mv /home/vivek/docs/files/resumezzz.pdf /home/vivek/docs/files/resume.pdf
    Use the ls command to view files:

    Code:
    ls -l file1
    ls -l file1 file2
    ls -l /home/vivek/docs/files/*.pdf
    ls -l *.pdf

  2. #2
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    Linux rename a file syntax

    In short, to rename a file:

    Code:
    mv file1 file2
    You can get verbose output i.e. mv command can explain what is being done using the following syntax:

    Code:
    mv -v file1 file2
    Sample outputs:

    Code:
    `file1' -> `file2'
    To make mv interactive pass the -i option. This option will prompt before overwriting file:

    Code:
    mv -i file1 file2
    Sample outputs:

    Code:
    mv: overwrite `file2'? y

  3. #3
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    Detailed information about mv command

    You can also view the manual page on mv using the following command:

    Code:
    man mv
    OR

    Code:
    info mv

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •