The Parameter is Incorrect

So, I could get neither xCopy nor BlueDog's DavCopy to work so I had to revert to brute force.

The problem is that UNC paths can use goofy characters like &, #, ~, ,, and . and URL paths can't.  So when, in some file share, you've got a file named "Snakes & Arrows.doc" when you try to upload that to a doc library you get the error "The Parameter is Incorrect."

We also run into this error when a file type is on the Firbidden File Types list in Central Admin and when we get a ~AAA9999.tmp file like when Word or Excel is auto-saving a draft, although I'm not sure why one would be left on the file share unless Word exits abnormally.

Now, we had over 15,000 documents in 2700 doc libraries.  So we went to scrubbing file name using a combination of the DOS Dir command, Notepad, Excel and DOS batch files.

First, for example, to find all the files with an & in the filename, we mapped a drive, L:, to the target file share and ran this from a command prompt:

DIR L:*&*.* /S /B /N >c:and.txt

That creates a file in the root of your c: drive named and.txt and it will list all the files and all the folders on the L: drive with an & in the file name.

Open the text file and copy and paste the content into Column A of an Excel worksheet.

Now, you have to use Excel string magic to remove one layer of directories labels at a time. So, in Column B, use this formula:

=IF(ISERROR(FIND("",A1,1)),A1,REPLACE(A1,1,FIND("",A1,1),""))

Then repeat that formula in subsequent columns to the right until you're left with a column with only the file names; this will depend on how deep your folders nest.  Copy the column of file names and use Paste Special | Values to paste the values, not the formulas, into a column of a new worksheet.  Then, on this worksheet, execute a find and replace, replacing the & with the string "and".

Copy the modified column and paste it back on the original worksheet in the next available column; if your original directory had folders as many as five layers deep, Column H would be good.  So, now, you've got the original DIR output in column A and the scrubbed file name in column H. Move over to column I and use this formula.

=CONCATENATE("REN """,A1,""" """,H1,"""")

This formula creates a text string that looks something like this:

REN "L:MyFolder01MyFolder02Snakes & Arrows.doc" "Snakes and Arrows.doc"

Now, copy the cells on row 1 and paste them all the way down to the end of your list. (Don't bugger your column H, the one with the new file names.)  Then copy Row I, the one with all the REN statements and paste them into Notepad and save the file as and.bat.  Find it in Windows Explorer and double click on it.  If you want, you can run it from a command line and append a >andout.txt; that will give you a nice output file for figuring out what you've done.

One thing about this process is this:  If you've got an & in a folder name, the folder will get renamed first and then the files will return a "file not found" error.  You'll have through the whole process again.  Of course, you could fight through the spreadsheet and make the folder name changes last but that would be burdensome.

And, finally, once you've scrubbed away all the &'s you'll have to find the #'s, the ,'s and any other goofy character.  The ~'s are particularly difficult to find since I don't think DOS will find them; perhaps if we knew the appropriate escape method to actually find a file with a ~ in the file name we could. Finally, the dots, i.e. ., are only a problem when there's two of them at the end in front of the file extension like this: My Firm Inc..doc.

So we migrated 17,000 documents with all of these issues in just 8 about hours. I was dragging folders from one Explorer window to another where I had a drive mapped to my doc library.  The folders would take as much as 10 minutes to copy and, often, they would crap out because of a .tmp file or some file I had missed; the ~ files were real hard to find before they errored.  I learned that, typically, an Explorer click and drag copy routine will copy the files first and then the folders in reverse alphabetical order.  Regradless, I would often have to open a third Explorer window to search for the problem file without making the error boxes go away.  Fix the file name, or move it to a separate "problem" folder, and run the click and drag again.

So, at least for this robot, brute force wins out.

hth

-robot

 


Tags:

 
 
 

Comments are closed.