Is there a way to convert long file names into a truncated short form on pc? Is there a simple way to do this? I'm new to using the command prompt / PowerShell and don't fully understand what long scripts are doing and how to modify them.

I want to transfer all of my files to an external hard drive but many of the files are from a mac with long names and I receive an error when I try to transfer them.

  • Are you talking about using DOS filenames (8+3) or just shorter than they currently are. If so how would a script know what to name a file. You would need rules. Also what are the errors you are getting?, long filenames shouldn't be a problem on Windows 10 unless they are really long. – Peter Hahndorf Aug 13 '16 at 5:15
  • I would like to rename them to the DOS filename (8+3). The error I receive when transferring is file name too long. They are really long file names over the Windows limit. – Animatoring Aug 13 '16 at 14:48
  • It's really the long paths, not long names because all modern filesystems support filenames of 255 characters. Another possibility is names containing special characters like *:\/? which are allowed in POSIX but not in Win32 namespace. So the problem isn't that you need 8.3 DOS names but Windows compatible names – phuclv Dec 24 '16 at 9:05
  • @ Animatoring, have you finally found a solution for creating 8+3 filenames along with long ones in Windows 10? I don't want to post a similar question. It would be a duplicate! – Apostolos Nov 24 '19 at 16:06

Save the following into a file Set-DosFileName.ps1


$fso = New-Object -ComObject Scripting.FileSystemObject

Get-ChildItem -Path $folder -File -Recurse:$recurse | ForEach-Object {

    $shortName = $fso.getfile($_.Fullname).ShortName
    if ($shortName -ne $_.Name)
        $fullShortName = Join-Path $_.Directory -ChildPath $shortName
        Move-Item -LiteralPath $_.Fullname -Destination $fullShortName

To use this open a PowerShell window and change into the directory where you saved the file:

cd "D:\folder where you saved the script"


.\Set-DosFileName.ps1 -folder "D:\myfiles\Foo Bar" -whatif

The script should show how it would rename your files.

To include all files in subdirectories add the -recurse switch:

.\Set-DosFileName.ps1 -folder "D:\myfiles\Foo Bar" -whatif -recurse

If everything looks fine, remove the -whatif switch to actually rename the files. I would still keep a backup of the original files just in case anything goes wrong.

I haven't tested this with a large number of files, be aware that some file names may be pretty ugly.


Since Windows 10 Version 1607, the file path length limit is removed. To enable this, open regedit.exe, go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem and create a DOWRD 32Bit LongPathsEnabled and change the value to 1.

enter image description here

Now the 260 char issue is gone.

  • I tried this but I'm not having any luck unfortunately. If you go to rename a long file after doing the changes above it doesn't give the option on my computer. I created a reg_dword for LongPathsEnabled and set it to 1. Did I forget to do something? Thanks! – Animatoring Aug 16 '16 at 23:02
  • ok, the app has to optin via an manifest entry. I haven't checked if explorer has the entry, but I think it should – magicandre1981 Aug 17 '16 at 4:16
  • Thanks! I noticed I didn't have the most current version that had the ability to enable the long paths. I think it should work now. – Animatoring Aug 17 '16 at 4:28
  • probably he has names with special characters like ?\/* which are not allowed in Windows – phuclv Dec 24 '16 at 9:07
  • Really? Does this answer the question "Convert long file names to short names" ??? In fact, it is for the exact opposite: How to create even longer file names by extending their length !!! – Apostolos Nov 24 '19 at 15:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.