Find the answer to your Linux question:
Results 1 to 8 of 8
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to move multiple files in ONE COMMAND to other dir?

    Sorry for this question:

    How do I move multiple files WITH ONE command (not through GUI) from one dir to another?

    The following command does not work:

    mv *.mp3 /var/www/backup/files/

    Linux terminal tells me:
    mv: call of stat for *.mp3 not possible: file or dir not found

    How else does it work?

    Related question: If I replace "mv" by "cp" in your solution: Does it work as well?


  2. #2
    Linux Engineer
    Join Date
    Apr 2012
    Virginia, USA
    That is the correct syntax for the command. The error is telling you that it cannot find anything that ends in .mp3 in the current directory.

  3. #3
    a better way to achieve your multi-file move command might be to use find and its -exec option instead, e.g.:

    find . -mindepth 1 -maxdepth 1 -type f -name '*.mp3' -exec mv -iv {} /var/www/backup/files/ \;
    that command will only move files that it finds in the current dir that end in '.mp3', and will prompt you before overwriting (-i). the {} in the above command is actually an internal variable used by find that represents each '.mp3' file found.

  4. $spacer_open
  5. #4
    you might have to move them as root to put them in to that directory.

  6. #5
    Are you sure it's not the destination folder that it can't find.

  7. #6
    Just Joined!
    Join Date
    Oct 2013
    Belleville, New Jersey
    I believe you are missing a . from the command you are using... try this...

    mv *.mp3 /var/www/backup/files/.

  8. #7
    Quote Originally Posted by kmelillo View Post
    I believe you are missing a . from the command you are using... try this...

    mv *.mp3 /var/www/backup/files/.
    the trailing "." after the directory there doesn't do anything different. e.g., it is the same as:

    mv *.mp3 /var/www/backup/files/
    using the "." usually comes in handy when you are specifying a relative (versus absolute) directory path.

    to avoid confusion to future readers of this thread, mizzle's explanation of the original problem is accurate.

  9. #8
    Just Joined!
    Join Date
    Jun 2013
    Just tried this on my own machine, I moved two text files to my desktop running this command. Try using my format and tell me if that works
    mv test.txt test2.txt ~/Desktop
    Here is quick bash script for future usage if you'd like to use it.

    read -p "Enter file names separated by a space: " files
    mv $files $path

Posting Permissions

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