bash error renaming files with spaces - mv target is not a directory

后端 未结 2 682
说谎
说谎 2021-02-12 15:48

I\'m trying to rename a bunch of files which contain spaces in them, getting rid of the spaces. I thought I found the correct bash command:

for f in *.txt; do m         


        
2条回答
  •  情深已故
    2021-02-12 16:03

    Because this is the first thing that came up on google when googling this error, I thought I'd add a bit.

    This error occurs if you have more than two arguments and the last result is not a directory.

    This works:

    mv file1.txt output.txt
    

    This does not:

    mv file1.txt file2.txt
    

    In my case I was doing: mv prefix_* output_file_name to ensure a downloaded file had a consistant name, but another file had appeared in the directory, restulting in the "mv target is not a directory" error

提交回复
热议问题