Scripting the File System, Part I: The Folder Object - Doc JavaScript | WebReference

Scripting the File System, Part I: The Folder Object - Doc JavaScript


Scripting the File System, Part I

The Folder Object

GetFolder(pathName)Object

This method returns the folder object of the given folder name. The following script should create a folder object for f:\yehuda\js\tips:

<SCRIPT LANGUAGE="JavaScript">
<!--
var fso = new ActiveXObject("Scripting.FileSystemObject");
folderObj = fso.GetFolder("f:\\yehuda\\js\\tips");
-->
</SCRIPT>

Here are the folder object's properties:

PropertyDescription
AttributesRefers to the folder attributes
DateCreatedReturns the folder's creation date
DateLastAccessedReturns the folder's last-accessed date
DateLastModifiedReturns the folder's last-modified date
DriveReturns the folder's letter drive
FilesReturns the folder's files collection, containing all the file objects in the folder
IsRootFolderReturns true if the folder is the root folder, false otherwise
NameReturns the folder name
ParentFolderReturns the folder's parent folder name
PathReturns the folder's long path
ShortNameReturns the folder's short name
ShortPathReturns the folder's short path
SizeReturns the folder size
SubFolderReturns a folder's collection of all folders contained in the folder
TypeReturns the folder type

Here are the folder object's methods:

MethodDescription
Copy()Copies the folder from one folder to another
Delete()Removes the folder
Move()Moves the folder from one folder to another

Next: How to use Drives and GetDrive()

http://www.internet.com


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: November 20, 2000
Revised: November 20, 2000

URL: http://www.webreference.com/js/column71/9.html