Edit in GitHubLog an issue

require('uxp').storage.Folder

Represents a folder on a file system. You'll never instantiate this directly, but will get it by calling FileSystemProvider.getTemporaryFolder, FileSystemProvider.getFolder, or via Folder.getEntries.

isFolder#

Indicates that this instance is a folder. Useful for type checking.

getEntries()#

Returns an array of entries contained within this folder.

Returns: Array.<Entry> - The entries within the folder.
Example

Copied to your clipboard
1const entries = await aFolder.getEntries();
2const allFiles = entries.filter(entry => entry.isFile);

createEntry(name, options)#

Creates an entry within this folder and returns the appropriate instance.

Returns: File | Folder - the created entry

ParamTypeDefaultDescription
namestringthe name of the entry to create
optionsany
[options.type]Symboltypes.fileIndicates which kind of entry to create. Pass folder to create a new folder. Note that if the type is file then this method just create a file entry object and not the actual file on the disk. The file actually gets created when you call for eg: write method on the file entry object.
[options.overwrite]booleanfalseIf true, the create attempt can overwrite an existing file

Example

Copied to your clipboard
const myNovel = await aFolder.createEntry("mynovel.txt");

Example

Copied to your clipboard
const catImageCollection = await aFolder.createEntry("cats", {type = types.folder});

createFile(name, options)#

Creates a File Entry object within this folder and returns the appropriate instance. Note that this method just create a file entry object and not the actual file on the disk. The file actually gets created when you call for eg: write method on the file entry object.

Returns: File - the created file entry

ParamTypeDefaultDescription
namestringthe name of the file to create.
optionsany
[options.overwrite]booleanfalseIf true, the create attempt can overwrite an existing file

Example

Copied to your clipboard
const myNovelTxtFile = await aFolder.createFile("mynovel.txt");

createFolder(name)#

Creates a Folder within this folder and returns the appropriate instance.

Returns: Folder - the created folder entry object

ParamTypeDescription
namestringthe name of the folder to create.

Example

Copied to your clipboard
const myCollectionsFolder = await aFolder.createFolder("collections");

getEntry(filePath)#

Gets an entry from within this folder and returns the appropriate instance.

Returns: File | Folder - the fetched entry.

ParamTypeDescription
filePathstringthe name/path of the entry to fetch

Example

Copied to your clipboard
const myNovel = await aFolder.getEntry("mynovel.txt");

renameEntry(entry, newName, options)#

Renames an entry to a new name.

ParamTypeDefaultDescription
entryEntrythe entry to rename
newNamestringthe new name to assign
optionsany
[options.overwrite]booleanfalseif true, renaming can overwrite an existing entry

Example

Copied to your clipboard
await myNovels.rename(myNovel, "myFantasticNovel.txt");

isFolder(entry)#

Checks if an entry is a folder. Safe to use if entry might be null or undefined. Useful for type checking.

Returns: boolean - if true, the entry is a folder

ParamTypeDescription
entryanythe entry to check
Copyright © 2021 Adobe. All rights reserved.