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:
-
Press and hold the Windows Key and R on the keyboard to open the Run popup.
-
Enter cmd
in the Open box and click OK.
Figure 2
-
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.
Figure 3
-
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
Figure 4
-
Open the Run window (see step 1), enter Excel
and click OK.
Figure 5
-
An Excel window will pop up. Click on Open.
Figure 6
-
Click Browse. You may need to slide the vertical bar in the center down (figure 7.b).
Figure 7.a
Figure 7.b
-
If the Open window has “Windows (C:) > Users > your S# > Documents” at the top, then skip to step 11.
Figure 8
-
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.
Figure 9.a
Figure 9.b
Figure 9.c
-
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.
Figure 10.a
Figure 10.b
Figure 10.c
-
Click on the drop-down next to “All Excel Files”.
Figure 11
-
Click on “Text Files” in the drop-down menu.
Figure 12
-
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.
Figure 13
-
Click on the Delimited radio button if it is not selected, then click Next.
Figure 14
-
In the “Delimiters” section, uncheck all boxes except for the “Other” box then click Next.
Figure 15
-
Click on the radio button for Text and click Finish.
Figure 16
-
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).
Figure 17.a
Figure 17.b
-
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.
Figure 18
-
Click File (Figure 19.a) and Save (Figure 19.b) to save the work done so far.
Figure 19.a
Figure 19.b
-
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.
Figure 20.a
Figure 20.b
-
Click on cell A1, input the following in the Formula Bar and hit enter:
=LEN(B1)
Figure 21.a
Figure 21.b
-
Click on cell A1 then press and hold Ctrl + C to select it as a cell to be copied.
Figure 22
-
Press and hold Ctrl + End to go to the last cell in column B which has data.
Figure 23.a
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.
-
Press the left arrow to go to the associated last cell in column A.
Figure 24
For example, in the figure 24, the active cell moved from B4007 to A4007.
-
Press and hold Ctrl + Shift + ↑ which will select all the cells in row A back to cell A1 at the top. (Figure 25)
Figure 25
-
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.
Figure 26
-
Now is a good point to save the work done so far. Follow step 19.
-
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.
-
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.
- Press H and release then press S and release.
- Press O and release. The worksheet should now be sorted by the values in column A.
Using the Sort on the Ribbon bar in Excel:
- Click Home on the menu bar.
- Click cell A1 to select it.
- Press and hold Ctrl + A to select all the cells containing data in the worksheet.
- Click the Sort & Filter button.
- Click Sort Largest to Smallest. The worksheet should now be sorted by the values in column A.
-
Now is a good point to save the work done so far. Follow step 19.
-
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.
Figure 31
-
Alternatively, if there are too many rows (hundreds or thousands) to go through using the mouse wheel:
-
Slide the bar to the right until you see some empty cells and click on one of the cells.
Figure 31.b.1
Figure 31.b.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.
Figure 31.b.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.
Figure 31.b.4
-
Click on the row number of the first cell which has a value less than 240 to select the row.
Figure 32
- 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.Figure 33
-
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.
Figure 34
-
Now is a good point to save the work done so far. Follow step 19.
-
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 &
and can cause extra characters.