none
Script to fix invalid characters for SharePoint synced share RRS feed

  • Question

  • I'm hoping for some help implementing a script that will rename files with characters that are invalid for SharePoint, in a synced file share that is accessed by everyone at an office.  

    Some background: I'm working for a small nonprofit that has a SBS 2012 server and a local domain with about 30 users. I'm the sole volunteer IT person here.  We have a network file share on the server that everyone stores their documents on.  Recently, we signed up with Office 365 Online and I set up a SharePoint library and synced it with the document share on our server.  A few files aren't being uploaded, though, because of invalid characters (For instance, a file like "Outline/Team plan #3.doc" )

    Expecting everyone to remember not to use any of the invalid characters isn't really a solution, particularly since I'm not here full-time if things go wrong.  I'm looking for a script to run on the server every few minutes that will rename any incompatible files so that they can be uploaded to SharePoint.  Personally, I think it's just plain criminal that Microsoft hasn't provided this functionality itself (it's the least they could do) but that's another rant for another time.  Unfortunately, while I do have a couple of years of experience with basic server administration and group policy, I'm not experienced at all when it comes to PowerShell scripting.  I can string together some command line commands in a batch file, and that's about it.  

    I did find this promising post here: 

    http://community.spiceworks.com/scripts/show/2097-fix-file-names-for-skydrive-pro-syncing

    I was hoping for opinions - is this the sort of thing I'm looking for, and what would be the best way to implement it (eg, every few minutes as a scheduled event)? Also, is this a straight-up powershell script, or are there additional languages/resources involved? (Like I said, I'm sort of a script newbie).

    Additional background: I posted a similar question asking if it could be done with GPOs, and they directed me here, suggesting it could be done with scripts. 

    Thanks!!



    • Edited by AGrush Thursday, April 10, 2014 10:58 PM
    Thursday, April 10, 2014 10:52 PM

Answers

  • That script that Mike linked to is a good one, i've used it myself a fair few times. Just to weigh in with a bit of information on why those characters are forbidden:

    The reason that some characters aren't allowed is that those characters are used as special characters in URLs. If you were to allow them to go into the file names (without 'escaping' them) then all the traffic to and from SharePoint would start to go horribly wrong.

    Now it is theoretically possible to build a tool that recognises the characters, escapes them, then uploads them. As well as updating the SharePoint interface to 'unescape' the characters when it renders them. However it's not a trivial bit of engineering, you'd have to gut SharePoint and re-do some of the core behaviour. You've then got to re-test it and make sure it doesn't break any previous SharePoint behaviour.

    The way MS want you to work is to save the files directly to SharePoint, which would pick up that you have protected characters and prompt the user to correct them. That does break down a bit with OneDrive as you can use the characters locally, it's only the next step that fails...

    Wednesday, April 16, 2014 3:01 PM

All replies

  • Thank you for your time, by the way.  I apologize if my original post comes off as sort of impatient or demanding.  I'm just still sort of steamed about this being an issue that there isn't an "official" fix for yet.

    That link looks quite promising.  I'll get back to you once I've had a chance to test it.
    Thanks!

    Monday, April 14, 2014 7:16 PM
  • =]

    No worries, I understand your frustration (and you're welcome). Hopefully that script does the trick for you.


    Don't retire TechNet! - (Don't give up yet - 12,830+ strong and growing)

    Monday, April 14, 2014 7:29 PM
  • That script that Mike linked to is a good one, i've used it myself a fair few times. Just to weigh in with a bit of information on why those characters are forbidden:

    The reason that some characters aren't allowed is that those characters are used as special characters in URLs. If you were to allow them to go into the file names (without 'escaping' them) then all the traffic to and from SharePoint would start to go horribly wrong.

    Now it is theoretically possible to build a tool that recognises the characters, escapes them, then uploads them. As well as updating the SharePoint interface to 'unescape' the characters when it renders them. However it's not a trivial bit of engineering, you'd have to gut SharePoint and re-do some of the core behaviour. You've then got to re-test it and make sure it doesn't break any previous SharePoint behaviour.

    The way MS want you to work is to save the files directly to SharePoint, which would pick up that you have protected characters and prompt the user to correct them. That does break down a bit with OneDrive as you can use the characters locally, it's only the next step that fails...

    Wednesday, April 16, 2014 3:01 PM
  • Now it is theoretically possible to build a tool that recognises the characters, escapes them, then uploads them. As well as updating the SharePoint interface to 'unescape' the characters when it renders them. However it's not a trivial bit of engineering, you'd have to gut SharePoint and re-do some of the core behaviour. 

    Now see, that's the breakdown for me. It is completely unacceptable for me that Microsoft would put this burden on users. The majority of staff are not tech savvy as it is, and now to migrate to OneDrive they are forced to manually change thousands of documents? 
    Wednesday, August 19, 2015 5:38 PM
  • This thread is closed.

    Complaints should be taken up with MSFT directly, not by adding on to the end of an answered thread.

    Note that you're not going to get any MSFT eyes here. These forums are filled with 99% non-MSFT people.


    Wednesday, August 19, 2015 5:43 PM
  • 1) This question is already marked answered.

    2) Your complaint is not a question.

    3) Nobody from the SharePoint or OneDrive teams monitors these forums for possible complaints.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, August 19, 2015 5:44 PM
    Moderator