{"id":2068,"date":"2021-05-24T14:22:45","date_gmt":"2021-05-24T14:22:45","guid":{"rendered":"https:\/\/www.sorcim.com\/blog\/?p=2068"},"modified":"2024-12-19T21:39:32","modified_gmt":"2024-12-19T21:39:32","slug":"how-to-shorten-the-length-of-long-file-names","status":"publish","type":"post","link":"https:\/\/www.sorcim.com\/blog\/how-to-shorten-the-length-of-long-file-names","title":{"rendered":"How to Fix Long File Path Errors in Windows and Rename Files"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">The maximum supported file path length in Windows is 260 characters. Windows may display an error when you exceed this limit. As a result, you may not be able to move, rename or even open such a file.<\/span><!--more--><\/p>\n<blockquote><p><strong>Rename multiple files in folders and subfolders. Utilize 10+ renaming rules. Also rename files on the Cloud. Use <a href=\"https:\/\/www.easyfilerenamer.com\/download\/ibx\" target=\"_blank\" rel=\"nofollow noopener\">Easy File Renamer<\/a> today!\u00a0<\/strong><\/p><\/blockquote>\n<p><b>Causes<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Setup programs and file compression programs are often a culprit. Sometimes, installation programs extract files to temporary directories and leave a large length of long file names.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Other times, simple file copying\/ moving operations cause this problem. If you\u2019re storing your data into long directories (for example, D:\\RootFolder\\SubFolder1\\SubFolder2\\SubFolder3), don\u2019t be surprised if you come across this problem.<\/span><\/p>\n<p><b>Solutions<\/b><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li aria-level=\"1\"><b>Using Windows PowerShell<\/b><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><b>Method 1: Remove Long Words from File Names<\/b><\/p>\n<p><span style=\"font-weight: 400;\">PowerShell is a command-line utility, much like Command Prompt. You can use PowerShell to run for automation and to perform various administrative tasks.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For example, if you\u2019ve a school album with hundreds of photos starting with a common word \u201cschoolmemories_\u201d (such as, schoolmemories_001.jpg, schoolmemories_002.jpg, schoolmemories_003.jpg, \u2026.), you can use the command given below which will strip off the word \u201cschoolmemories_\u201d from the file names, and make them short and simple.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Output:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">001.jpg<\/span><\/p>\n<p><span style=\"font-weight: 400;\">002.jpg<\/span><\/p>\n<p><span style=\"font-weight: 400;\">003.jpg<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Renaming files using PowerShell-<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Type PowerShell in the Search Box on your Taskbar.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Right-click Windows PowerShell in the Search Results and select Run as Administrator.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">In the newly opened window, type \u201cCD\u201d followed by the path to your folder. For example, \u201cCD D:\\SomeFolder\u201d.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Now, execute the following command to start renaming:<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">get-childitem *.* | foreach { rename-item $_ $_.Name.Replace(&#8220;schoolmemories_&#8221;, &#8220;&#8221;) }<\/span><\/p>\n<p><b>Method 2: Strip Off Specific Number of Characters from the Beginning of the File Name<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Another simple method is to remove a specific number of characters from the beginning of long file names. This is an ideal option if file names are not unique in nature, and they have different text patterns.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Open PowerShell.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Type \u201cCD\u201d followed by the target directory. For example: \u201cCD D:\\SomeFolder\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now, execute this command:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">get-childitem * | rename-item -newname { string.substring(16) }<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The above command will strip off the first 16 characters from each file name. If your original file names are schoolmemories_001.jpg, schoolmemories_002.jpg, schoolmemories_003.jpg, \u2026, the output file names will be 001.jpg, 002.jpg, 003.jpg, etc.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To limit the above command to only specific extensions (for example, only PDF documents), you can make some minor changes to it (as shown below)-<\/span><\/p>\n<p><span style=\"font-weight: 400;\">get-childitem *.pdf | rename-item -newname { string.substring(16) }<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You may replace .pdf with any other file type of your choice.<\/span><\/p>\n<ol>\n<li><b> Using Easy File Renamer (Recommended)<\/b><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Easy File Renamer, as the name describes, is a file renaming tool from industry-leading Sorcim Technologies.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Easy File Renamer has a user-friendly interface that makes it easy and fun to batch rename files without much effort. Additionally, there is no possibility of accidental data deletion, which is a critical concern in the case of command-line tools. For example, mistyped commands in PowerShell can do more harm than good. Within a few seconds, you could lose important data on your hard disk, or make it inaccessible and irrecoverable.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">With Easy File Renamer, the steps are fairly simple and straightforward:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Add your files (You may want to click on the Add Files option and select your files. Don\u2019t worry, you can select multiple files at once. You DO NOT need to add one file at a time).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select your desired renaming rule. A renaming rule is a criteria for renaming your files. For the purpose of this article, select Remove Text and specify the characters you want to strip off from the file names. For example, 5, 10, or 16.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Once you\u2019ve selected your rule, just click on Rename.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">That\u2019s it, it\u2019s that simple! No complex commands, no complex interface. With a few clicks, you can <\/span><a href=\"https:\/\/www.sorcim.com\/blog\/rename-part-of-filenames-in-multiple-files\"><span style=\"font-weight: 400;\">batch rename hundreds of files safely<\/span><\/a><span style=\"font-weight: 400;\"> and securely.<\/span><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The maximum supported file path length in Windows is 260 characters. Windows may display an error when you exceed this limit. As a result, you may not be able to move, rename or even open such a file.<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[869],"tags":[1105,1107,1108,1106],"class_list":["post-2068","post","type-post","status-publish","format-standard","hentry","category-rename-data","tag-how-to-shorten-the-length-of-long-file-names","tag-remove-long-words-from-file-names","tag-rename-using-easy-file-renamer","tag-strip-off-specific-number-of-characters-from-the-beginning-of-the-file-name"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.sorcim.com\/blog\/wp-json\/wp\/v2\/posts\/2068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sorcim.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sorcim.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sorcim.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sorcim.com\/blog\/wp-json\/wp\/v2\/comments?post=2068"}],"version-history":[{"count":4,"href":"https:\/\/www.sorcim.com\/blog\/wp-json\/wp\/v2\/posts\/2068\/revisions"}],"predecessor-version":[{"id":2626,"href":"https:\/\/www.sorcim.com\/blog\/wp-json\/wp\/v2\/posts\/2068\/revisions\/2626"}],"wp:attachment":[{"href":"https:\/\/www.sorcim.com\/blog\/wp-json\/wp\/v2\/media?parent=2068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sorcim.com\/blog\/wp-json\/wp\/v2\/categories?post=2068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sorcim.com\/blog\/wp-json\/wp\/v2\/tags?post=2068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}