locked
Script to Fix invalid file names? RRS feed

  • Question

  • I am not sure when it happened.  I am running a Windows Home Server 2011 and when renaming some media files and folders using an MP3 tagging program some of the names where set to invalid characters.  Some of these are easily handled, others... Not so much.  In particular, the folders with trailing "." are really hard to name/rename/delete.  I found that I can manually rename these using the "rd" with the short dos name, however I got so many of them that I can not do this manually.  You can't copy the parent directory if it contains a directory with a "."!  It doesn't give an error message, it just does nothing.  Makes you think it copied it.  It didn't... What a peace of garbage this is.  If I programmed like this I would be fired.

    I have looked everywhere for a solution, and the ONLY one that I can find that works is either on LINUX or costs $65, thats rediculous.  I tried various powershell scripts and batch scripts with limited success.

    Does anyone have anything that will go through a file tree and find all the issues and fix it?  All of the solutions I see from Microsoft do not run on Servers.  This is sad, I have spent 10 hours on this issue.  It seems like a VERY common issue.  Microsoft should check their file names BEFORE they save them.  The issue is FURTHER deepened because if you try and copy the parent directory of one of these folders using the File Explorer you only get SOME files and NO error message.  Once again, wasting time because of Microsoft.

    My mistake was clear, trusting a Microsoft OS as a server.  Now that I am locked in because of some hardware choices I am stuck...  This is sad.

    Thursday, October 13, 2016 12:20 AM

Answers

  • Hi,

    Sorry for the inconvenience caused to you.

    >>I found that I can manually rename these using the "rd" with the short dos name, however I got so many of them that I can not do this manually

    I suppose we could try using command:

    Get-ChildItem -Path C:\share -Recurse -Exclude '*.txt' -Include op.csv | Rename-Item -NewName op.csv
    Move-Item -Path source_path -Destination des_path -Force

    Besides, sorry I have no Windows home server 2011 for testing.

    It you need more assistances, welcome to post here.

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Proposed as answer by Hello_2018 Friday, October 21, 2016 9:14 AM
    • Marked as answer by Hello_2018 Monday, November 7, 2016 7:12 AM
    Friday, October 14, 2016 9:25 AM

All replies

  • BTW, If you share the parent folder then try to copy with Windows 10, you get a generic error.  Windows provides no clue as too what is wrong.

    Better then Windows Home Server 2011 that says nothing.  Doesn't give you an error message, just never copys anything.  Makes you think you copied it.  It didn't.

    Thursday, October 13, 2016 12:23 AM
  • Hi,

    Sorry for the inconvenience caused to you.

    >>I found that I can manually rename these using the "rd" with the short dos name, however I got so many of them that I can not do this manually

    I suppose we could try using command:

    Get-ChildItem -Path C:\share -Recurse -Exclude '*.txt' -Include op.csv | Rename-Item -NewName op.csv
    Move-Item -Path source_path -Destination des_path -Force

    Besides, sorry I have no Windows home server 2011 for testing.

    It you need more assistances, welcome to post here.

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Proposed as answer by Hello_2018 Friday, October 21, 2016 9:14 AM
    • Marked as answer by Hello_2018 Monday, November 7, 2016 7:12 AM
    Friday, October 14, 2016 9:25 AM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Andy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, October 21, 2016 9:14 AM