Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method. ShortName property returns the short name of the specified file or folder according to the 8.3 naming convention of file system. According to 8.3 naming system file names or folder names must have at most 8 characters to name them and not more than 3 characters to specify their extensions. This naming convention was introduced to make all types of file systems could share the compatible naming conventions to read the long file names. Old DOS or FAT based systems work on 8.3 naming convention whereas modern Computer systems running on NT based platforms are capable of reading long file names. ShortName property of FSO enables you to get the short file name according to 8.3 naming standards that could be used as platform independent file names.
Syntax for Javascript FSO ShortName property
fileObj.ShortName // or folderObj.ShortName
fileObj object has been used in the first syntax that could be retrieved from GetFile method which further provides the access to ShortName property and returns the short name of the specified file. Similarly folderObj used in the second syntax could be retrieved from GetFolder method which also provides the access to the ShortName property and returns the short name of the specified folder.
Example 1
File object to get the value of ShortName property
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// object created for file object returned by GetFile method
var fileObj = fso.GetFile("C:\\Temp\\New Text Document.txt");
document.write("<b>File Name : </b>" + fileObj.Name);
document.write("<br />");
document.write("<b>File ShortName : </b>" + fileObj.ShortName);
document.write("<br />");
// Output:
// File Name : New Text Document.txt
// File ShortName : NEWTEX~1.TXT
</script>
Example 2
Folder object to get the value of SortName property
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// object created for folder object returned by GetFolder method
var folderObj = fso.GetFolder("C:\\Temp\\documents_folder");
document.write("<b>Folder Name : </b>" + folderObj.Name);
document.write("<br />");
document.write("<b>Folder ShortName : </b>" + folderObj.ShortName);
document.write("<br />");
// Output:
// Folder Name : documents_folder
// Folder ShortName : DOCUME~1
</script>
Continue to next tutorial: Javascript FSO ShortPath property to learn how to get the path of the speicified file or folder w.r.t 8.3 naming conventions.