4

I have downloaded audio with youtube-dl, and then I wanted to change name with mv:

mv "Powerwolf  - Resurrection By Erection-Hiu1hPdJk-Y.mp3" "Powerwolf - Resurrection by Errection.mp3
>"

But, when I want to do something with renamed file, bash prints:

root@bananapi:~/Music# mv "Powerwolf - Resurrection by Errection.mp3 " All
mv: cannot stat 'Powerwolf - Resurrection by Errection.mp3 ': No such file or directory

When I type ls -l, bash prints:

root@bananapi:/home/music/Music# root@bananapi:/home/music/Music# ls -l
total 3860
drwxr-xr-x 2 music music    4096 Apr 19 11:49 All
-rw-r--r-- 1 music music     360 Apr 19 12:34 download.py
drwxr-xr-x 2 music music    4096 Apr 19 11:48 Eleven
drwxr-xr-x 2 music music    4096 Apr 18 20:49 KlemenSlakonja
drwxr-xr-x 2 music music    4096 Apr 19 11:49 LittleBig
drwxr-xr-x 2 music music    4096 Apr 18 20:28 Powerwolf
-rw-r--r-- 1 root  root  3924591 Oct 24 15:03 Powerwolf - Resurrection by Errection.mp3 ?

Now, I want to delete this file, but I can't.

  • 1
    Is there ? at the end of the filename? – Arkadiusz Drabczyk Apr 19 at 10:58
  • I think so, because bash prints it in "ls -l" – NOrBIxPLL Apr 19 at 10:59
  • besides, why did you change the spelling of "erection" to err e double r in the target file? that looks painful. – mosvy Apr 19 at 11:18
  • 1
    Ooops, that's my mistake – NOrBIxPLL Apr 19 at 11:22
6

Your initial mv renamed the file to a name containing a newline at the end. You forgot to close the quoted string of the new name and pressed Enter. After pressing Enter (inserting a newline), you closed the double quote. This inserted a newline into the filename.

To rename the file, use

mv $'Powerwolf - Resurrection by Errection.mp3 \n' 'Powerwolf - Resurrection by Errection.mp3'

Note the space before the \n. It looks like this should be there according to the ls output.

You could also use a * to match the end of the name with a newline:

mv "Powerwolf - Resurrection by Errection.mp3"* "Powerwolf - Resurrection by Errection.mp3"
  • That works, thaks! – NOrBIxPLL Apr 19 at 11:04
0

You seem to have a newline character at the end of your new file name. It appears you have pressed Enter before you typed the closing quote " at the end of your mv command. In order to correct that, type

mv "Powerwolf - Resurrection by Errection.mp3   <---  Press Enter here
" "Powerwolf - Resurrection by Erection.mp3"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.