How to find long path and file names

Body

Overview

The purpose of this knowledge base article is to help find the number of characters in the path of a file and all the subfolders it is nested under. EIT is requesting everyone move their data from legacy file shares, which reside on local servers, to the Microsoft 365 environment SMU has adopted. There is a lot more space, better security of your data, and it is easily accessible from on or off campus.

If you want to access your files in SharePoint, OneDrive, or Teams from Windows Explorer, then the path and file name to any file cannot exceed 240 characters. The file will show up when using the web client or SharePoint, OneDrive, or Teams, but will not show up in Windows Explorer.

Teams, OneDrive, and SharePoint cannot store files with paths longer than 380 characters. When you try to copy a file from another source, such as your laptop’s C: drive, into Teams, OneDrive, and SharePoint, you will get an error and the file will not copy.

In order to use the steps in the document, you will need to be on campus using an SMU computer that your J drive gets mapped on when you log in. The library or Atrium are places that do not map J drives.

To Find Long Paths:

  1. Press and hold the Windows Key and R on the keyboard to open the Run popup.

  2. Enter cmd in the Open box and click OK.

    Uploaded Image (Thumbnail)

    Figure 2

  3. The Command window will open. You may want to widen the window so that the command in the next step will fit onto one line.

    Uploaded Image (Thumbnail)

    Figure 3

  4. Change s9999999 to your s# in the below dir command, cut and paste the entire command as a single line into the CMD window. It is okay if it wraps to the next line when pasted, but do not copy part of the command, hit enter to the next line, then cut and paste the rest of the command. Hit enter and wait for the command to finish running. It could take up to 2 minutes to run.

   dir /s /b j:\ | sort /r /+240 /o c:\users\s9999999\Documents\jDrivePathNames.txt

 

Uploaded Image (Thumbnail)

Figure 4

  1. Open the Run window (see step 1), enter Excel and click OK.

    Uploaded Image (Thumbnail)

    Figure 5

  2. An Excel window will pop up. Click on Open.

    Uploaded Image (Thumbnail)

    Figure 6

  3. Click Browse. You may need to slide the vertical bar in the center down (figure 7.b).

    Uploaded Image (Thumbnail)

    Figure 7.a

    Uploaded Image (Thumbnail)

    Figure 7.b

  4. If the Open window has “Windows (C:) > Users > your S# > Documents” at the top, then skip to step 11.

    Uploaded Image (Thumbnail)

    Figure 8

  5. Click in the box at the top as outlined in yellow and press Ctrl + C then Ctrl + X to clear the contents in the box.

    Uploaded Image (Thumbnail)

    Figure 9.a

    Uploaded Image (Thumbnail)

    Figure 9.b

    Uploaded Image (Thumbnail)

    Figure 9.c

  6. Replace S1234567 with your s number in the text below, cut and paste it into the empty box and hit enter. The box will then display the name associated with the S# and Documents.

    C:\Users\s1234567\documents
    

    Note: Documents under Desktop in the menu to the left may be on your OneDrive and not in the local Windows documents folder where you saved the file in step 4.

    Uploaded Image (Thumbnail)

    Figure 10.a

    Uploaded Image (Thumbnail)

    Figure 10.b

    Uploaded Image (Thumbnail)

    Figure 10.c

  7. Click on the drop-down next to “All Excel Files”.

    Uploaded Image (Thumbnail)

    Figure 11

  8. Click on “Text Files” in the drop-down menu.

    Uploaded Image (Thumbnail)

    Figure 12

  9. Click on the file created in step 4 (e.g., jDrivePathNames.txt) and click the Open button.

    Note: TXT may not appear at the end of the file name as file extensions are normally hidden in Windows.

    Uploaded Image (Thumbnail)

    Figure 13

  10. Click on the Delimited radio button if it is not selected, then click Next.

    Uploaded Image (Thumbnail)

    Figure 14

  11. In the “Delimiters” section, uncheck all boxes except for the “Other” box then click Next.

    Uploaded Image (Thumbnail)

    Figure 15

  12. Click on the radio button for Text and click Finish.

    Uploaded Image (Thumbnail)

    Figure 16

  13. Switch from an unformatted text file to a spreadsheet formatted Excel file. Do this by clicking on File (figure 17.a) and in the drop-down menu click on Save As (figure 17.b).

    Uploaded Image (Thumbnail)

    Figure 17.a

    Uploaded Image (Thumbnail)

    Figure 17.b

  14. a. Click the drop-down arrow next to the Save button. Refer to #1 in figure 18.
    b. In the drop-down menuclick on “Excel Workbook (*.xlsx).” Refer to #2 in figure 18.
    c. Click the Save button.

    Uploaded Image (Thumbnail)

    Figure 18

  15. Click File (Figure 19.a) and Save (Figure 19.b) to save the work done so far.

    Uploaded Image (Thumbnail)

    Figure 19.a

    Uploaded Image (Thumbnail)

    Figure 19.b

  16. Right-click on the A cell at the top of column A and click on Insert in the drop-down menu (Figure 20.a). This will insert a blank column to the left of the paths and file names (Figure 20.b) now in column B. It will be easier to see and work with the number of characters in a path/filename if it is the first column.

    Uploaded Image (Thumbnail)

    Figure 20.a

    Uploaded Image (Thumbnail)

    Figure 20.b

  17. Click on cell A1, input the following in the Formula Bar and hit enter:

    =LEN(B1)
    
    Uploaded Image (Thumbnail)

    Figure 21.a

    Uploaded Image (Thumbnail)

    Figure 21.b

  18. Click on cell A1 then press and hold Ctrl + C to select it as a cell to be copied.

    Uploaded Image (Thumbnail)

    Figure 22

  19. Press and hold Ctrl + End to go to the last cell in column B which has data.

    Uploaded Image (Thumbnail)

    Figure 23.a

    Uploaded Image (Thumbnail)

    Figure 23.b

    On some keyboards press and hold Ctrl + Fn + End/Right ARROW, such as figure 23.b.

    Note: Ctrl + Shift + ↓ from cell A1 doesn’t always go to the last cell in row A which has data beside it in column B, but instead goes to the bottom of the worksheet.

  20. Press the left arrow to go to the associated last cell in column A.

    Uploaded Image (Thumbnail)

    Figure 24

    For example, in the figure 24, the active cell moved from B4007 to A4007.

  21. Press and hold Ctrl + Shift + ↑ which will select all the cells in row A back to cell A1 at the top. (Figure 25)

    Uploaded Image (Thumbnail)

    Figure 25

  22. Press and hold Ctrl + V to paste the formulas into the highlighted cells in row A. Each cell in row A will now show the number of characters in the corresponding cell in column B. For example, in the figure, cell B4004 has 22 characters as indicated in cell A4004.

    Uploaded Image (Thumbnail)

    Figure 26

  23. Now is a good point to save the work done so far. Follow step 19.

  24. Enter A1 in the “active cell” box and hit enter. This box is found above column A as shown highlighted in yellow above in figure 26.

  25. Sort by the values in column A from greatest character length to least. Here are two ways to do this sort:

    Using keys on the keyboard:

    • Press the Alt key next to the space bar and release.Uploaded Image (Thumbnail)
    • Press H and release then press S and release.Uploaded Image (Thumbnail)
    • Press O and release. The worksheet should now be sorted by the values in column A.Uploaded Image (Thumbnail)Uploaded Image (Thumbnail)

    Using the Sort on the Ribbon bar in Excel:

    • Click Home on the menu bar.Uploaded Image (Thumbnail)
    • Click cell A1 to select it.
    • Press and hold Ctrl + A to select all the cells containing data in the worksheet.Uploaded Image (Thumbnail)
    • Click the Sort & Filter button.Uploaded Image (Thumbnail)
    • Click Sort Largest to Smallest. The worksheet should now be sorted by the values in column A.Uploaded Image (Thumbnail)
  26. Now is a good point to save the work done so far. Follow step 19.

  27. Go to the first cell in row A that is less than 240. Here are two ways to do this:

    • Scroll down or use the Page Down key on the keyboard to the first cell in column A that is less than 240 characters and click on the row number to highlight the row.

      Uploaded Image (Thumbnail)
      Figure 31
    • Alternatively, if there are too many rows (hundreds or thousands) to go through using the mouse wheel:

      1. Slide the bar to the right until you see some empty cells and click on one of the cells.

        Uploaded Image (Thumbnail)

        Figure 31.b.1

        Uploaded Image (Thumbnail)

        Figure 31.b.2

      2. Enter =MATCH(240,A:A,-1) in the bar next to FX and hit enter. The value displayed in the cell is the row number in column A that is closest to 240. For example, the value 8 in cell C3.

        Uploaded Image (Thumbnail)

        Figure 31.b.3

      3. Enter A and the number from the previous step in the “current cell” box and hit enter. The active cell will move to the number entered.

        Uploaded Image (Thumbnail)

        Figure 31.b.4

  28. Click on the row number of the first cell which has a value less than 240 to select the row.

    Uploaded Image (Thumbnail)

    Figure 32

  29. Press and hold Ctrl + Shift + ↓ to go to the last row of the worksheet with data. This will also select the rows from the starting row to the end.Uploaded Image (Thumbnail)Figure 33
  30. Press Ctrl + - to delete the rows between the first one that was less than 240 to the last row that has data. All these rows have a length less than 240 characters so they can be ignored.

    Uploaded Image (Thumbnail)
    Figure 34
  31. Now is a good point to save the work done so far. Follow step 19.

  32. The names of the subfolders and file names on each row left in the spreadsheet. Some tips to decrease the work are:

    • By starting the renames from the left of the path (topmost folders) will shorten a lot of paths in the chain and lessen the number of rows that have similar upper paths.
    • Decreasing redundancy of words in the path. For example, changing …/…./…./Rules and Regulations Archives/Rules Archives/…./…./ to …/…./…./Rules and Regulations Archives/Rules/…./…./. The word "Archives" is already stated in the directory above the subfolder. This change will save 10 characters (including the space) on all subfolders and files under that directory.
    • A simple change is to remove spaces and use an uppercase letter for each new word in a name, such as 2360IntroductionToFinance instead of 2360 Introduction to Finance.
    • Rearrange the name to get rid of words, such as PublicWashroomsAndClassroomsRenovations instead of Renovations to public washrooms and classrooms.
    • Abbreviate words, such as PublicWashroomsAndClassroomsRenos instead of PublicWashroomsAndClassroomsRenovations.

    Note: The use of & for the word “and” gets stored as &amp and can cause extra characters.

Details

Details

Article ID: 921
Created
Thu 12/19/24 10:14 AM
Modified
Fri 12/20/24 8:16 AM