Recursively delete files of a certain extension - File name is too long (Win Server 2012)

0

A while back, I created .hash files for all files in a given folder structure for verification purposes. I no longer need them and they are minor annoyance/cause for alarm. I am trying to recursively del them using del /S *.hash but I am running into the "filename is too long" error. There are tons of these files, so I cannot simply rename them.

Any help would be greatly appreciated!

Mattj7

Posted 2017-01-26T01:48:15.190

Reputation: 1

1there are some great ideas on the linked thread in Dario's answer. I personally like to use the subst command to link the directory containing the file to b:\\ so that the path is compressed to 3 characters and the rest can be used for filename. other than that, using ~ name abbreviation as described in the linked question works pretty well as long as your filename is unique in its first 6 chars. – Frank Thomas – 2017-01-26T05:30:16.700

Answers

0

I believe this questions has been asked once or twice before. I had a quick search and found this : How to delete a file in Windows with a too long filename?

Have a look and see if this assists you, if not, let me / us know and will see what else can be done....

The simplest and best answer seems to be this one from @hectorpal : Using Robocopy

Darío Martín

Posted 2017-01-26T01:48:15.190

Reputation: 100

Thanks, I've read that thread and I don't know if I can apply any of the suggestions to this application....

I may be able to use the shortened name solution by printing to a text file and then modifying that text file to be a series of commands... – Mattj7 – 2017-01-26T01:59:47.377

Ah - this came through just as I edited the answer - take a look at http://superuser.com/a/1048242/652596 as @hectorpal describes using robocopy

– Darío Martín – 2017-01-26T02:11:01.790

I can't wrap my head around how to do that just to .hash files though. These are all suggestions for removing entire folders, which I don't want to do, the data is very important. – Mattj7 – 2017-01-26T14:03:03.203

Yep - sorry got that after re-reading your post. OK ... Would I be correct in thinking that they are deep within a sub-folder structure? i.e. C:\folder1\folder2\folder3\longfilename.hash and may well appear in all of the sub-folders, so you need to go through each sub-folder and delete only the .hash files ... do I understand correctly? – Darío Martín – 2017-01-30T02:18:17.333