theweaselking: (Work now)
[personal profile] theweaselking
Had an accident with a file copying script that left me with a pair of folders I couldn't access or delete. They had names with an unprintable character in them, so copy, move, delete, rename, etc, even with auto name completion, would say the file didn't exist. The problem is, the standard tools doing the standard thing aren't actually *seeing* the real filename, so they can't affect it.

The trick is classic MICROS~1, literally: Open a command line, use "dir /x" to find the actual 8.3 filename, which, since it has a character that's not printable in DOS, gets rewritten as "filena~1". Which is a name that the DOS tools can address - they're all built around the idea of taking non-DOS-legal filenames and converting them to 8.3 and then working on that instead of the real name ANYWAY, so they don't actually care that the smarter tools vomit on whatever character that is.

So, yeah. dir /x pops out the MICROS~1 name, and from there you can do cd, del, rmdir, whatever you want to it.

This is here mostly for my own reference. And hey, you might find it useful someday.

(no subject)

Date: 2011-10-26 02:54 am (UTC)
maelorin: (brawndo)
From: [personal profile] maelorin
typical ms.

this stunt can be used to create and use directories that are 'visible', but unusable by most people. if you set them as 'hidden' in properties, they're practically impossible for most users to find.

this one goes all the way back to ms first efforts to go beyond 8.3

you'll note ms still relies on the .3+ to 'determine' filetype and as the hook for applications. *headdesk* and this is despite the fact that most apps look at the magic number anyway *sigh*

(no subject)

Date: 2011-10-26 01:46 pm (UTC)
From: [identity profile] ice-hesitant.livejournal.com
Linux shell still uses the #!/bang/path to determine filetype (and dies stupidly if the path ends with a crlf instead of an lf). *headdesk*

The horror stories I've read about mimetype hijacking or resource fork hijacking or however it works on Mac OS X don't endear me to that approach either.

(no subject)

Date: 2011-10-26 11:51 am (UTC)
From: [identity profile] skington.livejournal.com
Another thing to try (and this works on Linux machines as well) is to get a directory listing, then delete the file, from within your preferred programming language. That avoids shell metacharacters and other weirdness. I recommend e.g.

perl -de0

but any similar language that has, effectively, a shell mode (and therefore doesn't require you to open up an editor) would work.

(no subject)

Date: 2011-10-26 12:43 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
True, but that requires a not-guaranteed-to-be-installed tool.

I'm sure Explorer replacements a la whatever people use these days instead of Norton commander could also do it, in much the same way - but this way does it with stuff that's definitely there already.

(no subject)

Date: 2011-10-26 12:51 pm (UTC)
From: [identity profile] skington.livejournal.com
I'd expect to find Perl on any stock Linux install.

(no subject)

Date: 2011-10-26 01:58 pm (UTC)
jerril: A cartoon head with caucasian skin, brown hair, and glasses. (Default)
From: [personal profile] jerril
The post is titled "Stupid Windows Tricks", and you'd be amazed how few Windows machines come with a Linux partition standard...
Although, do the Live-boot CDs for (frex) Ubuntu come with perl? That would work.

(no subject)

Date: 2011-10-26 02:18 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
I believe Ubuntu comes with perl - and even if it didn't, you can run Aptitude and install perl on your liveCD instance post-boot.

(no subject)

Date: 2011-10-26 02:20 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
Last I checked, "Windows" was not a stock Linux install.

(no subject)

Date: 2011-10-26 02:29 pm (UTC)
From: [identity profile] skington.livejournal.com
Yeah, sorry; I was mostly thinking about people stumbling across this post but not actually looking for Windows-related stuff.

(no subject)

Date: 2011-10-26 09:08 pm (UTC)
From: [identity profile] jsbowden.livejournal.com
But all of this on a unix system is irrelevant anyway. ls -i is your friend, and when you work directly with inodes, you don't care what the actual names are.

(no subject)

Date: 2011-10-26 01:35 pm (UTC)
frith: (peacock)
From: [personal profile] frith
I assume the unprintable-filename annoyances were just about the only things left in that "x" subdirectory with the target filename extension.

(no subject)

Date: 2011-10-26 01:59 pm (UTC)
jerril: A cartoon head with caucasian skin, brown hair, and glasses. (Default)
From: [personal profile] jerril
/x isn't a subdirectory - its a command line switch. Because Bill Gates decided to use \ as the path character, so he couldn't use it for command line switches... *facepalm*

(no subject)

Date: 2011-10-26 02:20 pm (UTC)
maelorin: (more charismatic than this)
From: [personal profile] maelorin
i always thought 'backwards compatibility' was one of the most accurately named business strategies.

(no subject)

Date: 2011-10-26 10:25 pm (UTC)
frith: Cosgrove/Onuki (anime retelling) (Luna sad)
From: [personal profile] frith
Oops! Thanks for the refresher. And I thought I was so hot, remembering my coursework from 25 years ago and DOS from 20 years ago. ^_^;

(no subject)

Date: 2011-10-26 02:19 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
What she said about the "/x" being a switch. And the ACTUAL folder containing the annoying folders was "Desktop", which is a real bitch of a thing to try to clean out brute-force-like.

(no subject)

Date: 2011-10-26 02:21 pm (UTC)
maelorin: (security of your shit)
From: [personal profile] maelorin
yup.

(no subject)

Date: 2011-10-26 10:32 pm (UTC)
frith: Cosgrove/Onuki (anime retelling) (Luna sad)
From: [personal profile] frith
That's what I was afraid of, thousands of files to rummage through. Not a happy thought.

(no subject)

Date: 2011-10-26 10:59 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
Not even "thousands", just "more than I care to lose with grosser methods"

(no subject)

Date: 2011-10-26 03:47 pm (UTC)
From: [identity profile] eididdy.livejournal.com
I ran across this situation months ago and had no luck finding any solution. This worked though, thanks!

Profile

theweaselking: (Default)theweaselking
Page generated Mar. 1st, 2026 03:28 pm