Solved

Rename long file names powershell script

Posted on 2014-10-27
2
1,853 Views
Last Modified: 2014-11-24
Hi Guys,

I need to migrate a share to a different location, however quite a few of the files within the folder share is very long, therefore when i attempt to migrate i get the error:

“File name(s) would be too long for the destination folder. You can shorten the file or try a destination that has a shorter path."

is there a powershell script i can use to rename these long file names?

thank you in advance,
Kelly
0
Comment
Question by:Kay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40406775
Here is a script to find all of the files that are longer than 260 characters so you can rename them yourself. It wouldn't be a good idea to automatically rename files, they may get lost.

Just replace C:\ with the path you want to check.

Get-ChildItem "C:\" -recurse | Where {$_.GetType().Name -match "File" -and $_.FullName.length -ge 260} | Foreach {$_.FullName}

Open in new window


If you want it to save to file instead of listing on screen just add
 | Out-File C:\filelist.txt

Open in new window

0
 
LVL 10

Accepted Solution

by:
Joe Klimis earned 500 total points
ID: 40435091
Which version of windows are you using ?  
I would recommend using robocopy utility , it is much faster than Powershell   and restartable if interrupted

Robocopy comes with windows and to get help on the syntax open a   robocopy /?

Robocopy "C:\OriginalShare" "\\Machine2\newshare" /MIR

Open in new window

2

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An article on effective troubleshooting
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question