MacOS – How to remove or rename a folder with a “bad” name on El Capitan

findermacosterminal

On my iMac I have a folder, left from preceding systems, named "ZipIt 2.2.2␀". I cannot delete or rename it, nor delete the files it contains, both from the Finder and from Terminal. Looking at this question and related answers I understand this is a bug of Mac OS 10.11 (and later?), connected to the presence of NUL character in the name.

I haven't an older Mac OS at hand. I tried to rename the folder with Onyx and A Better Finder Rename 10 but without success. I also tried to boot from Mac OS Recovery but couldn't do anything useful.

Any ideas?

EDIT.

Here's the output I get from Terminal when using find:

    % ls -li
    total 0
    1067625 drwxrwxrwx+ 6 root  wheel  204 25 Mag  2011 ZipIt 2.2.2␀

    % sudo find . -inum 1067625 -mount -exec rm -rf {} \;
    rm: ./ZipIt 2.2.2␀/.DS_Store: Invalid argument

[... many similar lines ...]

    rm: ./ZipIt 2.2.2␀: Invalid argument

EDIT 2.

I thought of a possible way out, but don't know if it's viable. I could create a new user, transfer the offending folder to its desktop, then delete the user.

Do you think this could be effective? I'd like to try, but I'm afraid this could hang the whole system.

EDIT 3

As requested by Allan, here's the detailed content of the folder I cannot delete:

% find . -type d -name 'Zip*' -print0 | xargs -0 -J -t ls
./ZipIt 2.2.2␀:
Drop files here to zip (OS_X)   ZipIt.app
Read me.pdf

./ZipIt 2.2.2␀/ZipIt.app:
Contents    ZipIt

./ZipIt 2.2.2␀/ZipIt.app/Contents/Resources/ZipIt Help:
ZipIt Help idx  ZipIt help  faq     images

Best Answer

Using the bash shell, you can try the completion feature. Example

Ravens-Claw:tmp garex$ mkdir "this\ is\ a\ bad\ folder\ with\ äü\ encoding"
Ravens-Claw:tmp garex$ ls -ltr | tail -1
drwxr-xr-x  2 garex  wheel   68 13 Jun 19:17 this\ is\ a\ bad\ folder\ with\ äü\ encoding
Ravens-Claw:tmp garex$ rm -rf "this\\ is\\ a\\ bad\\ folder\\ with\\ äü\\ encoding"/

Just type rm -rf "this, hit TAB key and bash will do the rest. Don't forget to close the ".

For files with strange filenames, you can try:

rm -- "<start typing filename and hit TAB key>"