Link to home
Create AccountLog in
Avatar of bleggee
bleggeeFlag for United States of America

asked on

Long Filesnames with Invalid Characters in them - Windows

Hi all - I have 10000+ files with bad characters ... like "?" in the filname, and they file names are very long.   Is there a quick/easy util to go thru filenames & fix this?  I don't care what the resulting filename is ... as long as it is shortened and the bad characters are gone. Right now, with Windows7, I am unable to copy/open etc
Avatar of Thommy
Thommy
Flag of Germany image

Maybe AntRenamer could help you...
Ant Renamer
Try to change the location of the zip or folder as it may be way back in the parent directory.
Try to cut the folder, make a new folder in Drive C and paste it, try to open as normal or unzip.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Bill Prew
Bill Prew

And I should mention, if you are running into long filenames, one way to deal with those is to use SUBST to "map" a drive to the folder name that has the files in it.  Then you may be able to rename them to shorter names there.  For example if you have a filename that is too long of:

c:\dir1\dir2\dir3\dir4\filename.txt

then do something like this:

subst z: c:\dir1\dir2\dir3\dir4
z:
ren filename.txt f.txt
c:
subst z: /d

Open in new window

~bp
Does this work?

Drop this batch file in the folder containing your files and run it from there - don't worry, it won't rename itself!

You can remove line 8 if you don't want to see a running progress in the titlebar.

@echo off
setlocal enabledelayedexpansion

set count=0
for %%a in (*) do (
  if not "%%~nxa"=="%~nx0" (
    set /a count+=1
    title !count!
    ren "%%a" File!count!%%~xa
  )
)

Open in new window

Just a thought...

The following XCOPY command will copy all the files in the current folder to a destination folder. The system will force the copied files to be written in short filename format.

xcopy *.* destination\ /c /n

Open in new window

Give it a try. It might be all you need - especially if the resultant short filename does not containt any special characters. If they do, you can run the code in my previous comment which will rename them to:

File1.???
File2.???
File3.???
etc...
Where '???' is the original extension name of the file.
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
Avatar of bleggee

ASKER

After evaluating Ant Renamer, I went with Bulk Renamer utility ... thanks all!
Welcome.

~bp