Link to home
Start Free TrialLog in
Avatar of David Mundt
David MundtFlag for United States of America

asked on

Removing Folder using Powershell when it contains Illegal Filenames Created by Mac

I'm trying to remove some folders but there were files created with Mac that the filenames are too long for Windows. Does anyone know how to force a folder delete no matter what is in it.

The file names are literally a sentence.

Below is the message I'm getting on PS.




PS C:\Users\david.mundt> Remove-Item -path "E:\Shared\Client Projects\Adobe" -recurse
Remove-Item : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less
than 248 characters.
At line:1 char:1
+ Remove-Item -path "E:\Shared\Client Projects\Client" -recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (E:\Shared\Client Projects\Client:String) [Remove-Item], PathTooLongException
    + FullyQualifiedErrorId : RemoveItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Mundt

ASKER

Thanks gentlemen. The Path too long tool worked for some of my folders but in the end I used

robocopy c:\empty "d:\folders I cant delete\illegal filenames" /mir

Success...
Avatar of Bill Prew
Bill Prew

Glad you solved your problem.


»bp
Glad to help. :)
Thanks gentlemen. The Path too long tool worked for some of my folders but in the end I used

robocopy c:\empty "d:\folders I cant delete\illegal filenames" /mir

Success...
try long path tool program,very good