I had an interesting problem develop and I have learned a few things while addressing it.
The problem was that a USB external drive formatted to NTFS ended up with a few files on it that contained illegal characters.
Some of the file names were like this:
Code: Select all
jelly?stuff.txt
jelly:stuff.txt
jelly//_stuff.txt
Anyway, the files got there by FreeFileSync copying the files over from an EXT4 fixed drive on my computer.
Windows could not even see the drive. Refused to even view it.
On Linux I could see the files, but not rename the files (remove the illegal characters), even with the terminal. It would say something like file not found. Of course I'm saying this for the NTFS drive.
rmdir -r dir
and rmdir -r filename
would not work either. It would say something like directory not found.I installed Detox, but oddly that would not work either no matter what I did. I don't think it worked on ? or :, but it definitely did not work on //_. Also gave a file not found error. Probably Detox is to fix the name on the EXT4 partition before you copy over??
So what was the solution? I saw on a website to use chkdsk /f f: in Windows. Oddly enough, after about 30 minutes it worked. It changed the offending filenames and would browse the drive. And back to Linux and FFS worked good. It did create another directory that probably shouldn't have been created, but overall it worked good. It pains me to give MS any credit at all, but I must in this case.
I have 2 questions:
How could I have fixed this in Linux?
How can I search an EXT4 partition for all NTFS "illegal characters"? Maybe something like this:
find . -type f -iname '*[:?/]*'
I suspect there are more illegal characters than I have listed.