1

I am using Fedora 24.

I have tried many different ways to do this. I've tried it under a Windows VM with the folder in question as a shared folder.

I've tried using the 'rename' command.

I've tried using the 'mv' command.

I've tried renaming them in 'Files'.

I've tried setting the filename to a variable with inode and then renaming. (lost the source)

26477098 'File | With Pipe.png'
xyz=`ls -i|grep 26477098|sed 's/26477098 //'`
mv "$xyz" File\ --\ With\ Pipe.png
mv: cannot stat 'File | With Pipe.png': No such file or directory

I keep getting the 'No such file or directory' error whatever way I try and do this.

I've also tried renaming them by using their inode number ("mv" file with garbled name by inode number?)

26477098 'File | With Pipe.png'
[user@computer Pictures]$ find . -inum 26477098 -exec mv {} File\ --\ With\ Pipe.png \;
mv: cannot move './File | With Pipe.png' to 'File -- With Pipe.png': No such file or directory
[user@computer Pictures]$ find . -inum 26477098 -print0 | xargs -0 mv -t a.png
mv: failed to access 'a.png': No such file or directory

If I try to open the file, it says "No images found..."

I was thinking maybe I could hard link to the inode and then try and delete the original file, but I can't figure out a way to do that.

Any thoughts?

*****************************EDIT*************************************

[risshuu@centurion Pictures]$ mv "File | With Pipe.png" "File -- With Pipe.png" 
mv: cannot stat 'File | With Pipe.png': No such file or directory
[risshuu@centurion Pictures]$ mv File\ \|\ With\ Pipe.png File\ --\ With\ Pipe.png
mv: cannot stat 'File | With Pipe.png': No such file or directory

I have quite a few of these files, and none of these work on them.

I just created a new file with a pipe and I have no problem renaming it to not have the pipe in it. There must be something else going on as well because I can't 'cat' the contents or open the file--I can't even remove any of the files! Are there any other file verification commands or something I can use or ways I can delete these files from the filesystem??

Risshuu
  • 19
  • Are you sure there are no other special characters? ls -b will show them. – Stephen Harris Jun 29 '16 at 13:01
  • Yes, I am sure. ls -b actually doesn't even escape the pipe: it shows File\ |\ With\ Pipe.png. – Risshuu Jun 29 '16 at 21:06
  • 2
    mv -i ./*File*With*Pipe*png* 'Fixed Filename.png' - make note of the quotes (none in the first filename) so that glob matching will handle the rest of the mess. – Stephen Harris Jun 29 '16 at 21:10
  • Thank you for trying to help me! I think that there is something else going on rather than the problem just being a pipe in the filename like I thought earlier. I tried using the command with the asterisks and I keep getting a "cannot stat" error. (I added more info to my post) – Risshuu Jun 29 '16 at 21:14
  • 2
    That's now beginning to sound like a corrupted filesystem! Or a non-native filesystem (NTFS? samba? FUSE?) which isn't playing clean... – Stephen Harris Jun 29 '16 at 21:16
  • Wow... how simple. It was because I was accessing it as a samba share. I SSH'd to the machine and it worked with no problems. Thank you so much! – Risshuu Jun 29 '16 at 21:24
  • Risshuu is this a mounted filesystem? if it is not a remote filesystem and not your root filesystem you can try running an fsck /dev/sd** on the filesystem – Citizen Zero Jun 29 '16 at 21:26
  • Yes, it was a mounted samba share. I was able to SSH into the machine and rename the files with no problems. – Risshuu Jun 29 '16 at 21:27

1 Answers1

6

You should be able to just escape the pipe use a backslash

mv te\|st test

Or in your case with the space

mv first\ \|\ last first_last 

If that does not work you can escape all the special characters by warping them with double quotes.

mv "first | last" first_last
  • Thanks. This is what I tried at the start. I did verify with a new file just to make sure and the new file worked while the old files I have do not. I think there might be something problem with the files themselves because I keep getting cannot stat errors. – Risshuu Jun 29 '16 at 21:22