Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

First study the enemy. Seek weakness. -- Romulan Commander, "Balance of Terror", stardate 1709.2


computers / alt.comp.os.windows-11 / Tip: when you can not detete that long file from the command line

SubjectAuthor
* Tip: when you can not detete that long file from the command lineT
`- Re: Tip: when you can not detete that long file from the command linePaul

1
Tip: when you can not detete that long file from the command line

<v04kql$o560$2@dont-email.me>

  copy mid

https://news.novabbs.org/computers/article-flat.php?id=5368&group=alt.comp.os.windows-11#5368

  copy link   Newsgroups: alt.comp.os.windows-10 alt.comp.os.windows-11
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: T@invalid.invalid (T)
Newsgroups: alt.comp.os.windows-10,alt.comp.os.windows-11
Subject: Tip: when you can not detete that long file from the command line
Date: Sun, 21 Apr 2024 20:16:37 -0700
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <v04kql$o560$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 22 Apr 2024 05:16:38 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="934c2023bbb45b3f13642b44e258ed8c";
logging-data="791744"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+39VKtgfKOAHSrpEU8+kuZzf7m9Rk8Frw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:O29YLwKlSKtcixABtFBOSzoi0mE=
Content-Language: en-US
 by: T - Mon, 22 Apr 2024 03:16 UTC

Hi All,

When you are trying to delete a a file
that has a very long file & path name ,
from the cmd line, powershell, your unlink
command within your compiler, and it just
wont delete. And you get the following
the returned error message of
"File not found"
And no you did not misspell it it.

But you can delete it with Windows
Explorer, here is what is going on.

Windows has two maximum file & path names
character lengths.

The default is called "MAX_PATH" and it is
260 characters long. Del and friends
makes an API (Application Program Interface)
call to DeleteFileA (UTF8) or DeleteFileW
(UTF16). The call lops off the extra
characters above MAX_PATH, so you
are trying to delete a different file name,
which is why the File Not Found error.

The solution is to use the other maximum,
non-default path limit of 32,767 characters.

To do this, prepend \\?\ to your path/file name.
Windows Explorer does this automatically
for you which is why it works. You can also
prepend this to shorter files without issue
(it is probably shower though.)

Some examples from the Raku (Perl6) module
I wrote to handle this. It returns OK if
the file got deleted or the error message
if not:

The Q[...] means a direct quote.("" does not work
so when used from the command line with Raku.)

Current directory path:
echo abc > eraseme.txt && raku -I. -e "use NativeDelete
:ApiDeleteFile; say ApiDeleteFile( Q[eraseme.txt] )" && type eraseme.txt
OK
The system cannot find the file specified.

Looking for the wrong file:
echo abc > eraseme.txt && raku -I. -e "use NativeDelete
:ApiDeleteFile; say ApiDeleteFile( Q[eraseme2.txt] )" && type eraseme.txt
The system cannot find the file specified.
abc

Long path from hell:
raku -I. -e "use NativeDelete :ApiDeleteFile; say ApiDeleteFile(
Q[\\?\D:\MyDocsBackup\backup2\Mozilla 2024-04-15 21;14;31
(Full)\Firefox\Profiles\pj0elosu.default-release\storage\default\https+++505991220932649.webpush.freshchat.com^partitionKey=%28https%2Cbid13.com%29\cache\morgue\114\{7cccd5e9-a7aa-4349-a2e9-569baf007272}.final]
);"
OK

HTH,
-T

Re: Tip: when you can not detete that long file from the command line

<v04qc1$p7h1$1@dont-email.me>

  copy mid

https://news.novabbs.org/computers/article-flat.php?id=5369&group=alt.comp.os.windows-11#5369

  copy link   Newsgroups: alt.comp.os.windows-10 alt.comp.os.windows-11
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nospam@needed.invalid (Paul)
Newsgroups: alt.comp.os.windows-10,alt.comp.os.windows-11
Subject: Re: Tip: when you can not detete that long file from the command line
Date: Mon, 22 Apr 2024 00:51:12 -0400
Organization: A noiseless patient Spider
Lines: 91
Message-ID: <v04qc1$p7h1$1@dont-email.me>
References: <v04kql$o560$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 22 Apr 2024 06:51:13 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="938e1b6807f18ee5091b8f300ce88782";
logging-data="826913"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/11Y+xdVV3/KIDIW9TpJRlOwMTKFUOp0g="
User-Agent: Ratcatcher/2.0.0.25 (Windows/20130802)
Cancel-Lock: sha1:uj3aIQmwp3+JKFAyBowfW88TaGo=
In-Reply-To: <v04kql$o560$2@dont-email.me>
Content-Language: en-US
 by: Paul - Mon, 22 Apr 2024 04:51 UTC

On 4/21/2024 11:16 PM, T wrote:
> Hi All,
>
> When you are trying to delete a a file
> that has a very long file & path name ,
> from the cmd line, powershell, your unlink
> command within your compiler, and it just
> wont delete.  And you get the following
> the returned error message of
>     "File not found"
> And no you did not misspell it it.
>
> But you can delete it with Windows
> Explorer, here is what is going on.
>
> Windows has two maximum file & path names
> character lengths.
>
> The default is called "MAX_PATH" and it is
> 260 characters long.  Del and friends
> makes an API (Application Program Interface)
> call to DeleteFileA (UTF8) or DeleteFileW
> (UTF16).  The call lops off the extra
> characters above MAX_PATH, so you
> are trying to delete a different file name,
> which is why the File Not Found error.
>
> The solution is to use the other maximum,
> non-default path limit of 32,767 characters.
>
> To do this, prepend \\?\ to your path/file name.
> Windows Explorer does this automatically
> for you which is why it works.  You can also
> prepend this to shorter files without issue
> (it is probably shower though.)
>
> Some examples from the Raku (Perl6) module
> I wrote to handle this.  It returns OK if
> the file got deleted or the error message
> if not:
>
> The Q[...] means a direct quote.("" does not work
> so when used from the command line with Raku.)
>
> Current directory path:
>       echo abc > eraseme.txt && raku -I. -e "use NativeDelete :ApiDeleteFile; say ApiDeleteFile( Q[eraseme.txt] )" && type eraseme.txt
>       OK
>       The system cannot find the file specified.
>
> Looking for the wrong file:
>       echo abc > eraseme.txt && raku -I. -e "use NativeDelete :ApiDeleteFile; say ApiDeleteFile( Q[eraseme2.txt] )" && type eraseme.txt
>       The system cannot find the file specified.
>       abc
>
> Long path from hell:
>       raku -I. -e "use NativeDelete :ApiDeleteFile; say ApiDeleteFile( Q[\\?\D:\MyDocsBackup\backup2\Mozilla 2024-04-15 21;14;31 (Full)\Firefox\Profiles\pj0elosu.default-release\storage\default\https+++505991220932649.webpush.freshchat.com^partitionKey=%28https%2Cbid13.com%29\cache\morgue\114\{7cccd5e9-a7aa-4349-a2e9-569baf007272}.final] );"
>       OK
>
> HTH,
> -T

In the backwoods where I live, permissions are likely to be the reason a file
cannot be removed.

NTFS New Compression is a close second. This should be
done as soon as humanly possible after an installation.

fsutil behavior set disablecompression 1 # disable New Compression

gpedit
computer configuration\Administrative template\system\filesystem\ntfs\Do not allow compression

A tablet with 32GB of storage, needs crutches like New Compression, for its
survival. Desktops with gobs of storage, this detritus should stay switched off.
That setting applies to all storage devices on the computer.

Microsoft has created filenames in C: (in a couple of areas related to products
you might pay for), where the character set was "unrepresentable". Attempting
to type or paste the wacky symbols simply will not work. But some manager at
MS must have given the Intern a kick in the bum for that, and the obnoxious structure
disappeared. It might have been considered to be an "exotic namespace". I think
CleanMgr could remove it, but you couldn't actually tell it to remove a specific
item, and only certain situations made removal possible ("Windows.old").

The "Length Bug" was removed some time ago. I could arrange a file to have
a certain length ("260"), it could not be removed in File Explorer, but a Perl rename()
could shorten the name enough to allow regular deletion. At a later point,
that rough spot was removed.

Paul

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor