# Unable to delete a weird directoryish



## DrCR (Nov 4, 2020)

After more than a decade of apathy and negligence, I'm finally cleaning up and organizing the data in my life e.g. running fslint on my venerable NAS (Debian with mdm), finishing getting rsnapshot setup, et al.

One step was moving data from an external HDD to my NAS. While cleaning up said data now on my NAS, I encountered a directoryish that I can't delete despite every trick I know. Note where it said it's a directory and not a directory in the command output. Odd, right? Thoughts on how i can get it deleted?

```
# ls
'Fran?ois Couperin'
#ls -lah
ls: 'Fran?ois Couperin': No such file or directory
total 0
drwxr-xr-x+ 3 jdoe jdoe 0 Nov  4 02:11  .
drwxr-xr-x+ 3 jdoe jdoe 0 Nov  3 11:40  ..
drwxr-xr-x  3 jdoe jdoe 0 Aug 15  2014 'Fran?ois Couperin'
# ls -il
ls: 'Fran?ois Couperin': No such file or directory
total 0
239210 drwxr-xr-x 3 jdoe jdoe 0 Aug 15  2014 'Fran?ois Couperin'
# find . -inum 239210 -exec rm -i {} \;
rm: cannot remove './Fran?ois Couperin': Is a directory
find: ‘./Fran?ois Couperin’: Not a directory
```

Note: I can cd into it. The below result is upon running ls -lah after cding into it.

```
# cd Fran\?ois\ Couperin/
.../Music/Fran?ois Couperin# ls -lah
ls: cannot open directory '.': No such file or directory
```


----------



## FinneousPJ (Nov 4, 2020)

I suspect the torrent had an illegal character. Did you try using quotes around the name? What filesystem is it?


----------



## DrCR (Nov 4, 2020)

Filesystem is jfs.

François Couperin was a baroque composer. Origin was a CD rip as that was my only music medium in that era. If it matters, it was originally on a Fat32 partition on the external drive before I brought it over to my jfs NAS yesterday. (I regularly used 4 different OSes any given day at the time, hence the use of Fat32.) Edit: My music listening  was done on a MBP though. I just now wondered if maybe OSX has better support for ç or some such, but in testing just now, I was able to touch and rm a ç named file without issue. Sadly I cannot check and see how well I can intereact with the original directory on the external HDD's Fat32 partition, as after copying everything over to the NAS, I zeroed it out.

Didn't try quotes as I was just using autocomplete via tabbing. Tried just now, to no avail. (Same result with "" as well.)


```
# ls
'Fran?ois Couperin'
# rm -r 'Fran?ois Couperin'
rm: cannot remove 'Fran?ois Couperin': No such file or directory
# rm -r 'Fran\?ois\ Couperin/'
rm: cannot remove 'Fran\?ois\ Couperin/': No such file or directory
# rm -r 'Fran\?ois\ Couperin'
rm: cannot remove 'Fran\?ois\ Couperin': No such file or directory
```

P.s. As a side note, mv does not work either.


----------



## FinneousPJ (Nov 4, 2020)

DrCR said:


> Filesystem is jfs.
> 
> François Couperin was a baroque composer. Origin was a CD rip as that was my only music medium in that era. If it matters, it was originally on a Fat32 partition on the external drive before I brought it over to my jfs NAS yesterday. (I regularly used 4 different OSes any given day at the time, hence the use of Fat32.)
> 
> ...


That's a tough one. Here are some tips that might work, like using a regular expression to catch the dir:








						Delete folder with invalid character (-encoding)
					

On my Linux Mint 18.3 installation I had troubles with my locale setting which caused the generation of a folder that has invalid encoding in its name.    I would now like to delete said folder but...




					unix.stackexchange.com
				




If those do not work and if you still have the original drive I would try fixing the name before copying over...


----------



## DrCR (Nov 4, 2020)

Good idea in trying a wildcard just in case. Still to no avail though.

```
# rm F*
rm: cannot remove 'Fran?ois Couperin': Is a directory
# rm -r F*
rm: cannot remove 'Fran?ois Couperin': No such file or directory
# rm -rfi F*
rm: descend into directory 'Fran?ois Couperin'? y
rm: cannot remove 'Fran?ois Couperin': No such file or directory
```


```
# find -maxdepth 1 -name F*
./Fran?ois Couperin
# find -maxdepth 1 -name F* -delete
find: cannot delete ‘./Fran?ois Couperin’: No such file or directory
```

What I find nutty is when I try to take the direct inode approach.

```
# find . -inum 239210 -exec rm -i {} \;
rm: cannot remove './Fran?ois Couperin': Is a directory
find: ‘./Fran?ois Couperin’: Not a directory
```


----------



## FinneousPJ (Nov 4, 2020)

And did you try rmdir?


----------



## DrCR (Nov 4, 2020)

Certainly. "No such file or directory".


----------



## DrCR (Nov 6, 2020)

Just a quick update.

After some other ineffectual steps and running fsck -f on /dev/md0 i.e. the mdadm raid drive on the NAS, since I was connected into the NAS anyway, I tried to delete the now infamous Fran\?ois\ Couperin while logged into the NAS itself -- and it deleted successfully.

I went to the other problematic files (all same origin of MBP iTunes, saved to Fat32, copied to NAS), and successfully deleted those as well while logged into the NAS.

So all set, though I'm completely baffled as to why I could not delete them via my linux clients.


----------



## Easy Rhino (Nov 7, 2020)

DrCR said:


> So all set, though I'm completely baffled as to why I could not delete them via my linux clients.



It depends on what shell environment you were using to execute the rm commands.


----------



## DrCR (Nov 8, 2020)

Bash, Gnome terminal in Ubuntu. Bash, Xfce terminal in Slackware.


----------



## DrCR (Nov 10, 2020)

Easy Rhino, is there something you'd recommend I'd try?


----------

