How to delete really loooooooooong file names?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
OM3
Posts: 32
Joined: 17 Mar 2014 08:43

How to delete really loooooooooong file names?

#1 Post by OM3 » 14 Feb 2017 07:55

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

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How to delete really loooooooooong file names?

#2 Post by aGerman » 14 Feb 2017 12:30

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

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: How to delete really loooooooooong file names?

#3 Post by ShadowThief » 14 Feb 2017 12:31

Where are you getting these long names from? I can't even create a file with a name+extension that exceeds 200 characters.

siberia-man
Posts: 208
Joined: 26 Dec 2013 09:28
Contact:

Re: How to delete really loooooooooong file names?

#4 Post by siberia-man » 14 Feb 2017 14:55

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"

kwsiebert
Posts: 43
Joined: 20 Jan 2016 15:46

Re: How to delete really loooooooooong file names?

#5 Post by kwsiebert » 15 Feb 2017 08:45

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.

Post Reply