renaming files with long names
February 23, 2015 1:32 PM   Subscribe

I would like to rename some files with long file names. I'd be happy deleting them. I'm using Windows 8(.?) They're in the "Music" folder. I don't know whether that complicates things. Things that haven't worked:

I can't delete them. Using Windows Explorer, I can't even right click on them. It just crashes. I can't rename or delete them from the command prompt. I get an error about the file names being too long. I downloaded Malwarebytes File Assassin and it didn't help. I downloaded Unlocker and I think I successfully avoided installing all the extra crap it comes with, but it didn't help either. At least it doesn't crash. I can right click on the files that I want to delete, but then it tells me that I can't delete it because the destination path (in the recycle bin?) is too long.

If I try to drag the music folder someplace with a shorter path, I just get a shortcut. I can't right click and cut it. Only the 'copy' option appears. If I try to move it from the command prompt, I get an access denied error. Besides, these file names are stupid long. I guess the limit is 255 characters, right? They're probably 255 characters on their own, so I don't see what good it would do to move them.

'dir /X' does nothing to help. 'dir /-n' actually helped a little. Some file names show up like "01CARL~1.FLA". I can use the del command to delete those and I managed to kill a couple that way. Most of the other files show up as "01CAR" or "21CARL~1.FL". Those are immune to del. The error is that the file cannot be found.
posted by stuart_s to Computers & Internet (6 answers total)
See if Bulk Rename Utility will help you.
posted by soelo at 1:37 PM on February 23, 2015

Download another file explorer program, like free commander or explorer++. Try to rename them. If that doesn't work, then try to highlight the offending files without crashing the program. If you can do that, press shift-Delete to bypass the recycle bin and delete them for good.
posted by trivia genius at 1:42 PM on February 23, 2015

When everything else fails - filenames in different languages with unprintable characters, that sort of thing - I usually use Python. You can run something like the following in Python's interactive shell:
import os
files = os.listdir('.')
for i in range(len(files)):
  print i, files[i]
0 abc.txt
1 foobar.txt
2 stupid name that can't be renamed.txt
os.rename(files[2], "easiername.txt")
That way you don't have to even be able to type the name of the file.
posted by clawsoon at 1:52 PM on February 23, 2015

alligatorman's link looks promising.

One thing I thought of that might not work if the file names are too long by themselves, but you can use the subst command to map a folder to a drive letter. This will reduce the path size by removing the folder path from the length.

subst J: C:\Users\yourname\Music

This will make your J: drive point to your music.
posted by zixyer at 1:55 PM on February 23, 2015

Alligatorman's link was what lead me to a solution. Robocopy has some sort of magic built in. First, I accidentally just made a second copy of all of the offending files. Oops. At least I learned that robocopy can handle the files. I was worried that robocopy wouldn't have any option for deleting files. After all, they don't call it robodelete. Anyway, there's a /MOV option which deletes the source file. In combination with the /FAT option, which gives the new copies friendly 8.3 names, I was able get rid of the offending files.

I hope you'll forgive me for not recreating my problem and testing out your other solutions. I've spent enough time on this today. Please know that all of your ideas were very much appreciated. For the benefit of those who may be referring to this question in the future, I'll note that a couple of the solutions did not work. Bulk Rename would show me the files, but when I asked it to rename them I got an error that they couldn't be found. When I tried to shift-delete the files in Explorer, I still got an error about a long path.

So, thanks again. Great answers and under 10 minutes at that.
posted by stuart_s at 2:16 PM on February 23, 2015

« Older Nein Mustache- natural solution for fade cream.   |   Looking for Good (and Free?) Lists of Literary... Newer »
This thread is closed to new comments.