Page 1 of 1

How to delete really loooooooooong file names?

Posted: 14 Feb 2017 07:55
by OM3
OK... so I've googled it
The the solutions seem to involved super complex answers

Why is there no easy and straight forward solution?

Why does this problem occur?
I can understand that users shouldn't be allowed to have a file name that is 1m chars long - but then set a limit and don't let the limit be exceeded in the first place

Anyway... whats the best way of solving?

Thanks

Re: How to delete really loooooooooong file names?

Posted: 14 Feb 2017 12:30
by aGerman
OM3 wrote:Why is there no easy and straight forward solution?
You should rather ask Microsoft.

OM3 wrote:Why does this problem occur?
Because there is a different handling on Windows of pathes in Unicode (UTF-16) that support long pathes and ANSI encoded pathes that support only 259 characters. Why? Ask Microsoft.

OM3 wrote:whats the best way of solving?
Since this forum is about Windows Batch I should suggest ROBOCOPY
http://superuser.com/questions/45697/ho ... lenameOK...
But note that the maximum length of a command line is 8191. Why? Ask Microsoft.

Steffen

Re: How to delete really loooooooooong file names?

Posted: 14 Feb 2017 12:31
by ShadowThief
Where are you getting these long names from? I can't even create a file with a name+extension that exceeds 200 characters.

Re: How to delete really loooooooooong file names?

Posted: 14 Feb 2017 14:55
by siberia-man
To answer to your question we need to know what are you meaning when you are saying "really long file name".
1. full path is too long. For example, c:\very\long\path-name\with\very-long-file-name could exceed the OS limitation (~8K chars per the object)
2. file name itself is too long. For example, c:\some\short\path\very-very-very-long-file-name.

It is not important how these cases was accomplished. Fro example, under cygwin it is possible. In this case use the same tool or application for deletion this kind of files.

One way - I guess it is true for the case #1 above

Code: Select all

subst x: c:\very\long\path-name\with
del x:\very-long-file-name
subst x: /d


Another way - use short names for deletion

Code: Select all

for %f in ( "c:\very\long\path-name\with\very-long-file-name" ) do @del "%~sf"

Re: How to delete really loooooooooong file names?

Posted: 15 Feb 2017 08:45
by kwsiebert
ShadowThief wrote:Where are you getting these long names from? I can't even create a file with a name+extension that exceeds 200 characters.

I've had a downloading plugin for Firefox create files that Windows itself said were invalid.