Table Row (tr) |
---|
| Table Head (th) |
---|
| Method Details |
|
Table Body (tbody) |
---|
id | appendToTXTFile |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
appendToTXTFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Boolean |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| appendToTXTFile |
Span |
---|
| (file/fileName, text, [encoding]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Appends data into a text file. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters file/fileName text [encoding] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
// append some text to a text file:
var ok = plugins.file.appendToTXTFile('myTextFile.txt', '\nMy fantastic new line of text\n');
|
|
|
|
|
Table Body (tbody) |
---|
id | convertToJSFile |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
convertToJSFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| convertToJSFile |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns a JSFile instance corresponding to an alternative representation of a file (for example a string). |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters file |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var f = plugins.file.convertToJSFile("story.txt");
if (f.canRead())
application.output("File can be read.");
|
|
|
|
|
Table Body (tbody) |
---|
id | convertToRemoteJSFile |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
convertToRemoteJSFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| convertToRemoteJSFile |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns the JSFile object of a server file, given its path (relative the default server location) |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters serverPath |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var f = plugins.file.convertToRemoteJSFile('/story.txt');
if (f && f.canRead())
application.output('File can be read.');
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Boolean |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| copyFile |
Span |
---|
| (sourceFile, destinationFile) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Copies the sourcefile to the destination file. Returns true if the copy succeeds, false if any error occurs. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters sourceFile destinationFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
// Copy based on file names.
if (!plugins.file.copyFile("story.txt", "story.txt.copy"))
application.output("Copy failed.");
// Copy based on JSFile instances.
var f = plugins.file.createFile("story.txt");
var fcopy = plugins.file.createFile("story.txt.copy2");
if (!plugins.file.copyFile(f, fcopy))
application.output("Copy failed.");
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
copyFolder |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Boolean |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| copyFolder |
Span |
---|
| (sourceFolder, destinationFolder) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Copies the sourcefolder to the destination folder, recursively. Returns true if the copy succeeds, false if any error occurs. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters sourceFolder destinationFolder |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
// Copy folder based on names.
if (!plugins.file.copyFolder("stories", "stories_copy"))
application.output("Folder copy failed.");
// Copy folder based on JSFile instances.
var d = plugins.file.createFile("stories");
var dcopy = plugins.file.createFile("stories_copy_2");
if (!plugins.file.copyFolder(d, dcopy))
application.output("Folder copy failed.");
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
createFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| createFile |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Creates a JSFile instance. Does not create the file on disk. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters targetFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
// Create the JSFile instance based on the file name.
var f = plugins.file.createFile("newfile.txt");
// Create the file on disk.
if (!f.createNewFile())
application.output("The file could not be created.");
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
createFolder |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Boolean |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| createFolder |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Creates a folder on disk. Returns true if the folder is successfully created, false if any error occurs. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters targetFolder |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var d = plugins.file.convertToJSFile(" |
|
|
|
| story.txtf.canRead(!plugins.file.createFolder(d))
application.output(" |
|
|
|
| Filecanread{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=convertToRemoteJSFile|class=node}{tr:id=name}{td}h6.convertToRemoteJSFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}convertToRemoteJSFile{span}{span:id=iets|style=float: left;}\(serverPath){span}{td}{tr}{tr:id=des}{td}{sub-section:convertToRemoteJSFile_des|text=|trigger=button}{sub-section}{sub-section:convertToRemoteJSFile_des|trigger=none|class=sIndent}Returns the JSFile object of a server file, given its path (relative the default server location){sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:convertToRemoteJSFile_snc|text=|trigger=button}{sub-section}{sub-section:convertToRemoteJSFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:convertToRemoteJSFile_prs|text=|trigger=button}{sub-section}{sub-section:convertToRemoteJSFile_prs|trigger=none|class=sIndent}serverPath
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:convertToRemoteJSFile_ret|text=|trigger=button}{sub-section}{sub-section:convertToRemoteJSFile_ret|trigger=none|class=sIndent}[JSFile]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:convertToRemoteJSFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:convertToRemoteJSFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:convertToRemoteJSFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:convertToRemoteJSFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:convertToRemoteJSFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:convertToRemoteJSFile_sam|trigger=none}{code:language=javascript}
var f = plugins.file.convertToRemoteJSFile('/story.txt');
if (f && f.canRead( Table Body (tbody) |
---|
id | createTempFile |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
createTempFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| createTempFile |
Span |
---|
| (filePrefix, fileSuffix) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Creates a temporary file on disk. A prefix and an extension are specified and they will be part of the file name. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters filePrefix fileSuffix |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var tempFile = plugins.file.createTempFile('myfile','.txt');
application.output('Temporary file created as: ' + tempFile.getAbsolutePath());
plugins.file.writeTXTFile(tempFile, 'abcdefg');
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
deleteFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Boolean |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| deleteFile |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Removes a file from disk. Returns true on success, false otherwise. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters targetFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
if (plugins.file.deleteFile('story.txt'))
application.output('File deleted.');
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
deleteFolder |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Boolean |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| deleteFolder |
Span |
---|
| (targetFolder, showWarning) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Deletes a folder from disk recursively. Returns true on success, false otherwise. If the second parameter is set to true, then a warning will be issued to the user before actually removing the folder. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters targetFolder showWarning |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
if (plugins.file.deleteFolder('stories', true))
application.output(' |
|
|
|
| File can be read{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=copyFile|class=node}{tr:id=name}{td}h6.copyFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}copyFile{span}{span:id=iets|style=float: left;}\(sourceFile, destinationFile){span}{td}{tr}{tr:id=des}{td}{sub-section:copyFile_des|text=|trigger=button}{sub-section}{sub-section:copyFile_des|trigger=none|class=sIndent}Copies the sourcefile to the destination file. Returns true if the copy succeeds, false if any error occurs.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:copyFile_snc|text=|trigger=button}{sub-section}{sub-section:copyFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:copyFile_prs|text=|trigger=button}{sub-section}{sub-section:copyFile_prs|trigger=none|class=sIndent}sourceFile
destinationFile
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:copyFile_ret|text=|trigger=button}{sub-section}{sub-section:copyFile_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:copyFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:copyFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:copyFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:copyFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:copyFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:copyFile_sam|trigger=none}{code:language=javascript}
// Copy based on file names.
if (!plugins.file.copyFile("story.txt", "story.txt.copy"))
application.output("Copy failed.");
// Copy based on JSFile instances.
var f = plugins.file.createFile("story.txt");
var fcopy = plugins.file.createFile("story.txt.copy2");
if (!plugins.file.copyFile(f, fcopy))
application.output("Copy failed.");
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=copyFolder|class=node}{tr:id=name}{td}h6.copyFolder{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}copyFolder{span}{span:id=iets|style=float: left;}\(sourceFolder, destinationFolder){span}{td}{tr}{tr:id=des}{td}{sub-section:copyFolder_des|text=|trigger=button}{sub-section}{sub-section:copyFolder_des|trigger=none|class=sIndent}Copies the sourcefolder to the destination folder, recursively. Returns true if the copy succeeds, false if any error occurs.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:copyFolder_snc|text=|trigger=button}{sub-section}{sub-section:copyFolder_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:copyFolder_prs|text=|trigger=button}{sub-section}{sub-section:copyFolder_prs|trigger=none|class=sIndent}sourceFolder
destinationFolder
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:copyFolder_ret|text=|trigger=button}{sub-section}{sub-section:copyFolder_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:copyFolder_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:copyFolder_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:copyFolder_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:copyFolder_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:copyFolder_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:copyFolder_sam|trigger=none}{code:language=javascript}
// Copy folder based on names.
if (!plugins.file.copyFolder("stories", "stories_copy"))
application.output("Folder copy failed.");
// Copy folder Table Body (tbody) |
---|
id | getDesktopFolder |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
getDesktopFolder |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getDesktopFolder |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns a JSFile instance that corresponds to the Desktop folder of the currently logged in user. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var d = plugins.file.getDesktopFolder();
application.output('desktop folder is: ' + d.getAbsolutePath());
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
getDiskList |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile[] |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getDiskList |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns an Array of JSFile instances correponding to the file system root folders. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns JSFile[] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var roots = plugins.file.getDiskList();
for (var i = 0; i < roots.length; i++)
application.output(roots[i].getAbsolutePath());
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
getFileSize |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Number |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getFileSize |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns the size of the specified file. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters targetFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var f = plugins.file.convertToJSFile('story.txt');
application.output('file size: ' + plugins.file.getFileSize(f));
|
|
|
|
|
Table Body (tbody) |
---|
id | getFolderContents |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
getFolderContents |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile[] |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getFolderContents |
Span |
---|
| (targetFolder, [fileFilter], [fileOption(1=files,2=dirs)], [visibleOption(1=visible,2=nonvisible)], [lockedOption(1=locked,2=nonlocked)]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters targetFolder [fileFilter] [fileOption(1=files,2=dirs)] [visibleOption(1=visible,2=nonvisible)] [lockedOption(1=locked,2=nonlocked)] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns JSFile[] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
application.output(files[i].getAbsolutePath());
|
|
|
|
|
Table Body (tbody) |
---|
id | getHomeDirectory |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
getHomeDirectory |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getHomeDirectory |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns a JSFile instance corresponding to the home folder of the logged in used. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var d = plugins.file.getHomeDirectory();
application.output('home folder: ' + d.getAbsolutePath());
|
|
|
|
|
Table Body (tbody) |
---|
id | getModificationDate |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
getModificationDate |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Date |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getModificationDate |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns the modification date of a file. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters targetFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns Date |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var f = plugins.file.convertToJSFile('story.txt');
application.output('last changed: ' + plugins.file.getModificationDate(f));
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
getRemoteList |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile[] |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getRemoteList |
Span |
---|
| (serverFolder/serverFolderPath, [filesOnly]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Retrieves a list of files existing in a folder on the server side (in the path provided, relative to the default server location) |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters serverFolder/serverFolderPath [filesOnly] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns JSFile[] |
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Boolean |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| moveFile |
Span |
---|
| (sourceFile, destinationFile) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Moves the file from the source to the destination place. Returns true on success, false otherwise. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters sourceFile destinationFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
// Move file based on names.
if (!plugins.file.moveFile('story.txt','story.txt.new'))
application.output('File move failed.');
// Move file based on JSFile instances.
var |
|
|
|
| dcreateFile("stories"convertToJSFile('story.txt.new');
var |
|
|
|
| dcopycreateFile("stories_copy_2")convertToJSFile('story.txt');
if (!plugins.file. |
|
|
|
| copyFolderddcopyfmoved))
application.output( |
|
|
|
| "Folder copy"{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createFile|class=node}{tr:id=name}{td}h6.createFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}createFile{span}{span:id=iets|style=float: left;}\(targetFile){span}{td}{tr}{tr:id=des}{td}{sub-section:createFile_des|text=|trigger=button}{sub-section}{sub-section:createFile_des|trigger=none|class=sIndent}Creates a JSFile instance. Does not create the file on disk.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:createFile_snc|text=|trigger=button}{sub-section}{sub-section:createFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:createFile_prs|text=|trigger=button}{sub-section}{sub-section:createFile_prs|trigger=none|class=sIndent}targetFile
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:createFile_ret|text=|trigger=button}{sub-section}{sub-section:createFile_ret|trigger=none|class=sIndent}[JSFile]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:createFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:createFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:createFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createFile_sam|trigger=none}{code:language=javascript}
// Create the JSFile instance based on the file name.
var f = plugins.file.createFile("newfile.txt");
// Create the file on disk.
if (!f.createNewFile())
application.output("The file could not be created.");
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createFolder|class=node}{tr:id=name}{td}h6.createFolder{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}createFolder{span}{span:id=iets|style=float: left;}\(targetFolder){span}{td}{tr}{tr:id=des}{td}{sub-section:createFolder_des|text=|trigger=button}{sub-section}{sub-section:createFolder_des|trigger=none|class=sIndent}Creates a folder on disk. Returns true if the folder is successfully created, false if any error occurs.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:createFolder_snc|text=|trigger=button}{sub-section}{sub-section:createFolder_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:createFolder_prs|text=|trigger=button}{sub-section}{sub-section:createFolder_prs|trigger=none|class=sIndent}targetFolder
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:createFolder_ret|text=|trigger=button}{sub-section}{sub-section:createFolder_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:createFolder_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createFolder_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:createFolder_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createFolder_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:createFolder_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createFolder_sam|trigger=none}{code:language=javascript}
var d = plugins.file.convertToJSFile("newfolder");
if (!plugins.file.createFolder(d))
application.output("Folder could not be created.");
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createTempFile|class=node}{tr:id=name}{td}h6.createTempFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}createTempFile{span}{span:id=iets|style=float: left;}\(filePrefix, fileSuffix){span}{td}{tr}{tr:id=des}{td}{sub-section:createTempFile_des|text=|trigger=button}{sub-section}{sub-section:createTempFile_des|trigger=none|class=sIndent}Creates a temporary file on disk. A prefix and an extension are specified and they will be part of the file name.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:createTempFile_snc|text=|trigger=button}{sub-section}{sub-section:createTempFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:createTempFile_prs|text=|trigger=button}{sub-section}{sub-section:createTempFile_prs|trigger=none|class=sIndent}filePrefix
fileSuffix
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:createTempFile_ret|text=|trigger=button}{sub-section}{sub-section:createTempFile_ret|trigger=none|class=sIndent}[JSFile]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:createTempFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createTempFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:createTempFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createTempFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:createTempFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createTempFile_sam|trigger=none}{code:language=javascript}
var tempFile = plugins.file.createTempFile('myfile','.txt');
application.output('Temporary file created as: ' + tempFile.getAbsolutePath());
plugins.file.writeTXTFile(tempFile, 'abcdefg');
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=deleteFile|class=node}{tr:id=name}{td}h6.deleteFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}deleteFile{span}{span:id=iets|style=float: left;}\(targetFile){span}{td}{tr}{tr:id=des}{td}{sub-section:deleteFile_des|text=|trigger=button}{sub-section}{sub-section:deleteFile_des|trigger=none|class=sIndent}Removes a file from disk. Returns true on success, false otherwise.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:deleteFile_snc|text=|trigger=button}{sub-section}{sub-section:deleteFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:deleteFile_prs|text=|trigger=button}{sub-section}{sub-section:deleteFile_prs|trigger=none|class=sIndent}targetFile
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:deleteFile_ret|text=|trigger=button}{sub-section}{sub-section:deleteFile_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:deleteFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:deleteFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:deleteFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:deleteFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:deleteFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:deleteFile_sam|trigger=none}{code:language=javascript}
if (plugins.file.deleteFile('story.txt'))
application.output('File deleted.');
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=deleteFolder|class=node}{tr:id=name}{td}h6.deleteFolder{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}deleteFolder{span}{span:id=iets|style=float: left;}\(targetFolder, showWarning){span}{td}{tr}{tr:id=des}{td}{sub-section:deleteFolder_des|text=|trigger=button}{sub-section}{sub-section:deleteFolder_des|trigger=none|class=sIndent}Deletes a folder from disk recursively. Returns true on success, false otherwise. If the second parameter is set to true, then a warning will be issued to the user before actually removing the folder.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:deleteFolder_snc|text=|trigger=button}{sub-section}{sub-section:deleteFolder_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:deleteFolder_prs|text=|trigger=button}{sub-section}{sub-section:deleteFolder_prs|trigger=none|class=sIndent}targetFolder
showWarning
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:deleteFolder_ret|text=|trigger=button}{sub-section}{sub-section:deleteFolder_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:deleteFolder_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:deleteFolder_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:deleteFolder_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:deleteFolder_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:deleteFolder_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:deleteFolder_sam|trigger=none}{code:language=javascript}
if (plugins.file.deleteFolder('stories', true))
application.output('Folder deleted.');
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getDesktopFolder|class=node}{tr:id=name}{td}h6.getDesktopFolder{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}getDesktopFolder{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:getDesktopFolder_des|text=|trigger=button}{sub-section}{sub-section:getDesktopFolder_des|trigger=none|class=sIndent}Returns a JSFile instance that corresponds to the Desktop folder of the currently logged in user.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:getDesktopFolder_snc|text=|trigger=button}{sub-section}{sub-section:getDesktopFolder_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:getDesktopFolder_prs|text=|trigger=button}{sub-section}{sub-section:getDesktopFolder_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:getDesktopFolder_ret|text=|trigger=button}{sub-section}{sub-section:getDesktopFolder_ret|trigger=none|class=sIndent}[JSFile]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:getDesktopFolder_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getDesktopFolder_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:getDesktopFolder_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getDesktopFolder_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:getDesktopFolder_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getDesktopFolder_sam|trigger=none}{code:language=javascript}
var d = plugins.file.getDesktopFolder();
application.output('desktop folder is: ' + d.getAbsolutePath());
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getDiskList|class=node}{tr:id=name}{td}h6.getDiskList{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getDiskList{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:getDiskList_des|text=|trigger=button}{sub-section}{sub-section:getDiskList_des|trigger=none|class=sIndent}Returns an Array of JSFile instances correponding to the file system root folders.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:getDiskList_snc|text=|trigger=button}{sub-section}{sub-section:getDiskList_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:getDiskList_prs|text=|trigger=button}{sub-section}{sub-section:getDiskList_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:getDiskList_ret|text=|trigger=button}{sub-section}{sub-section:getDiskList_ret|trigger=none|class=sIndent}[JSFile]\[]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:getDiskList_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getDiskList_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:getDiskList_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getDiskList_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:getDiskList_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getDiskList_sam|trigger=none}{code:language=javascript}
var roots = plugins.file.getDiskList();
for (var i = 0; i < roots.length; i++)
application.output(roots[i].getAbsolutePath());
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getFileSize|class=node}{tr:id=name}{td}h6.getFileSize{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Number]{span}{span:id=iets|style=float: left; font-weight: bold;}getFileSize{span}{span:id=iets|style=float: left;}\(targetFile){span}{td}{tr}{tr:id=des}{td}{sub-section:getFileSize_des|text=|trigger=button}{sub-section}{sub-section:getFileSize_des|trigger=none|class=sIndent}Returns the size of the specified file.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:getFileSize_snc|text=|trigger=button}{sub-section}{sub-section:getFileSize_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:getFileSize_prs|text=|trigger=button}{sub-section}{sub-section:getFileSize_prs|trigger=none|class=sIndent}targetFile
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:getFileSize_ret|text=|trigger=button}{sub-section}{sub-section:getFileSize_ret|trigger=none|class=sIndent}[Number]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:getFileSize_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getFileSize_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:getFileSize_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getFileSize_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:getFileSize_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getFileSize_sam|trigger=none}{code:language=javascript}
var f = plugins.file.convertToJSFile('story.txt');
application.output('file size: ' + plugins.file.getFileSize(f));
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getFolderContents|class=node}{tr:id=name}{td}h6.getFolderContents{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getFolderContents{span}{span:id=iets|style=float: left;}\(targetFolder, \[fileFilter\], \[fileOption(1=files,2=dirs)\], \[visibleOption(1=visible,2=nonvisible)\], \[lockedOption(1=locked,2=nonlocked)\]){span}{td}{tr}{tr:id=des}{td}{sub-section:getFolderContents_des|text=|trigger=button}{sub-section}{sub-section:getFolderContents_des|trigger=none|class=sIndent}Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:getFolderContents_snc|text=|trigger=button}{sub-section}{sub-section:getFolderContents_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:getFolderContents_prs|text=|trigger=button}{sub-section}{sub-section:getFolderContents_prs|trigger=none|class=sIndent}targetFolder
\[fileFilter\]
\[fileOption(1=files,2=dirs)\]
\[visibleOption(1=visible,2=nonvisible)\]
\[lockedOption(1=locked,2=nonlocked)\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:getFolderContents_ret|text=|trigger=button}{sub-section}{sub-section:getFolderContents_ret|trigger=none|class=sIndent}[JSFile]\[]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:getFolderContents_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getFolderContents_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:getFolderContents_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getFolderContents_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:getFolderContents_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getFolderContents_sam|trigger=none}{code:language=javascript}
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
application.output(files[i].getAbsolutePath());
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getHomeDirectory|class=node}{tr:id=name}{td}h6.getHomeDirectory{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}getHomeDirectory{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:getHomeDirectory_des|text=|trigger=button}{sub-section}{sub-section:getHomeDirectory_des|trigger=none|class=sIndent}Returns a JSFile instance corresponding to the home folder of the logged in used.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:getHomeDirectory_snc|text=|trigger=button}{sub-section}{sub-section:getHomeDirectory_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:getHomeDirectory_prs|text=|trigger=button}{sub-section}{sub-section:getHomeDirectory_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:getHomeDirectory_ret|text=|trigger=button}{sub-section}{sub-section:getHomeDirectory_ret|trigger=none|class=sIndent}[JSFile]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:getHomeDirectory_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getHomeDirectory_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:getHomeDirectory_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getHomeDirectory_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:getHomeDirectory_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getHomeDirectory_sam|trigger=none}{code:language=javascript}
var d = plugins.file.getHomeDirectory();
application.output('home folder: ' + d.getAbsolutePath());
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getModificationDate|class=node}{tr:id=name}{td}h6.getModificationDate{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Date]{span}{span:id=iets|style=float: left; font-weight: bold;}getModificationDate{span}{span:id=iets|style=float: left;}\(targetFile){span}{td}{tr}{tr:id=des}{td}{sub-section:getModificationDate_des|text=|trigger=button}{sub-section}{sub-section:getModificationDate_des|trigger=none|class=sIndent}Returns the modification date of a file.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:getModificationDate_snc|text=|trigger=button}{sub-section}{sub-section:getModificationDate_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:getModificationDate_prs|text=|trigger=button}{sub-section}{sub-section:getModificationDate_prs|trigger=none|class=sIndent}targetFile
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:getModificationDate_ret|text=|trigger=button}{sub-section}{sub-section:getModificationDate_ret|trigger=none|class=sIndent}[Date]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:getModificationDate_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getModificationDate_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:getModificationDate_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getModificationDate_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:getModificationDate_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getModificationDate_sam|trigger=none}{code:language=javascript}
var f = plugins.file.convertToJSFile('story.txt');
application.output('last changed: ' + plugins.file.getModificationDate(f));
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getRemoteList|class=node}{tr:id=name}{td}h6.getRemoteList{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getRemoteList{span}{span:id=iets|style=float: left;}\(serverFolder/serverFolderPath, \[filesOnly\]){span}{td}{tr}{tr:id=des}{td}{sub-section:getRemoteList_des|text=|trigger=button}{sub-section}{sub-section:getRemoteList_des|trigger=none|class=sIndent}Retrieves a list of files existing in a folder on the server side (in the path provided, relative to the default server location){sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:getRemoteList_snc|text=|trigger=button}{sub-section}{sub-section:getRemoteList_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:getRemoteList_prs|text=|trigger=button}{sub-section}{sub-section:getRemoteList_prs|trigger=none|class=sIndent}serverFolder/serverFolderPath
\[filesOnly\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:getRemoteList_ret|text=|trigger=button}{sub-section}{sub-section:getRemoteList_ret|trigger=none|class=sIndent}[JSFile]\[]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:getRemoteList_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getRemoteList_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:getRemoteList_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getRemoteList_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:getRemoteList_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getRemoteList_sam|trigger=none}{builder-show:permission=edit}{code:language=javascript}
{code}{builder-show}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=moveFile|class=node}{tr:id=name}{td}h6.moveFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}moveFile{span}{span:id=iets|style=float: left;}\(sourceFile, destinationFile){span}{td}{tr}{tr:id=des}{td}{sub-section:moveFile_des|text=|trigger=button}{sub-section}{sub-section:moveFile_des|trigger=none|class=sIndent}Moves the file from the source to the destination place. Returns true on success, false otherwise.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:moveFile_snc|text=|trigger=button}{sub-section}{sub-section:moveFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:moveFile_prs|text=|trigger=button}{sub-section}{sub-section:moveFile_prs|trigger=none|class=sIndent}sourceFile
destinationFile
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:moveFile_ret|text=|trigger=button}{sub-section}{sub-section:moveFile_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:moveFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:moveFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:moveFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:moveFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:moveFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:moveFile_sam|trigger=none}{code:language=javascript}
// Move file based on names.
if (!plugins.file.moveFile('story.txt','story.txt.new'))
application.output('File move failed.');
// Move file based on JSFile instances.
var f = plugins.file.convertToJSFile('story.txt.new');
var fmoved = plugins.file.convertToJSFile('story.txt');
if (!plugins.file.moveFile(f, fmoved))
application.output('File move back failed.');
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=readFile|class=node}{tr:id=name}{td}h6.readFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}byte[]{span}{span:id=iets|style=float: left; font-weight: bold;}readFile{span}{span:id=iets|style=float: left;}\(\[file\], \[size\]){span}{td}{tr}{tr:id=des}{td}{sub-section:readFile_des|text=|trigger=button}{sub-section}{sub-section:readFile_des|trigger=none|class=sIndent}Reads all or part of the content from a binary file. If a file name is not specified, then a file selection dialog pops up for selecting a file. (Web Enabled){sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:readFile_snc|text=|trigger=button}{sub-section}{sub-section:readFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:readFile_prs|text=|trigger=button}{sub-section}{sub-section:readFile_prs|trigger=none|class=sIndent}\[file\]
\[size\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:readFile_ret|text=|trigger=button}{sub-section}{sub-section:readFile_ret|trigger=none|class=sIndent}byte[]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:readFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:readFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:readFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:readFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:readFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:readFile_sam|trigger=none}{code:language=javascript}
// Read all content from the file.
var bytes = plugins.file.readFile('big.jpg');
application.output('file size: ' + bytes.length);
// Read only the first 1KB from the file.
var bytesPartial = plugins.file.readFile('big.jpg', 1024);
application.output('partial file size: ' + bytesPartial.length);
// Read all content from a file selected from the file open dialog.
var bytesUnknownFile = plugins.file.readFile();
application.output('unknown file size: ' + bytesUnknownFile.length);
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=readTXTFile|class=node}{tr:id=name}{td}h6.readTXTFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[String]{span}{span:id=iets|style=float: left; font-weight: bold;}readTXTFile{span}{span:id=iets|style=float: left;}\(\[file\], \[charsetname\]){span}{td}{tr}{tr:id=des}{td}{sub-section:readTXTFile_des|text=|trigger=button}{sub-section}{sub-section:readTXTFile_des|trigger=none|class=sIndent}Read all content from a text file. If a file name is not specified, then a file selection dialog pops up for selecting a file. The encoding can be also specified. (Web Enabled){sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:readTXTFile_snc|text=|trigger=button}{sub-section}{sub-section:readTXTFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:readTXTFile_prs|text=|trigger=button}{sub-section}{sub-section:readTXTFile_prs|trigger=none|class=sIndent}\[file\]
\[charsetname\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:readTXTFile_ret|text=|trigger=button}{sub-section}{sub-section:readTXTFile_ret|trigger=none|class=sIndent}[String]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:readTXTFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:readTXTFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:readTXTFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:readTXTFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:readTXTFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:readTXTFile_sam|trigger=none}{code:language=javascript}
// Read content from a known text file.
var txt = plugins.file.readTXTFile('story.txt');
application.output(txt);
// Read content from a text file selected from the file open dialog.
var txtUnknown = plugins.file.readTXTFile();
application.output(txtUnknown);
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=showDirectorySelectDialog|class=node}{tr:id=name}{td}h6.showDirectorySelectDialog{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}showDirectorySelectDialog{span}{span:id=iets|style=float: left;}\(\[directory suggestion\], \[dialog title text\]){span}{td}{tr}{tr:id=des}{td}{sub-section:showDirectorySelectDialog_des|text=|trigger=button}{sub-section}{sub-section:showDirectorySelectDialog_des|trigger=none|class=sIndent}Shows a directory selector dialog.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:showDirectorySelectDialog_snc|text=|trigger=button}{sub-section}{sub-section:showDirectorySelectDialog_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:showDirectorySelectDialog_prs|text=|trigger=button}{sub-section}{sub-section:showDirectorySelectDialog_prs|trigger=none|class=sIndent}\[directory suggestion\]
\[dialog title text\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:showDirectorySelectDialog_ret|text=|trigger=button}{sub-section}{sub-section:showDirectorySelectDialog_ret|trigger=none|class=sIndent}[JSFile]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:showDirectorySelectDialog_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:showDirectorySelectDialog_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:showDirectorySelectDialog_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:showDirectorySelectDialog_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:showDirectorySelectDialog_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:showDirectorySelectDialog_sam|trigger=none}{code:language=javascript}
var dir = plugins.file.showDirectorySelectDialog();
application.output("you've selected folder: " + dir.getAbsolutePath());
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=showFileOpenDialog|class=node}{tr:id=name}{td}h6.showFileOpenDialog{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Object]{span}{span:id=iets|style=float: left; font-weight: bold;}showFileOpenDialog{span}{span:id=iets|style=float: left;}\(\[selectionMode(0=both,1=Files,2=Dirs)\], \[startDirectory(null=default/previous)\], \[multiselect(true/false)\], \[filterarray\], \[callbackmethod\], \[dialog title text\]){span}{td}{tr}{tr:id=des}{td}{sub-section:showFileOpenDialog_des|text=|trigger=button}{sub-section}{sub-section:showFileOpenDialog_des|trigger=none|class=sIndent}Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled){sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:showFileOpenDialog_snc|text=|trigger=button}{sub-section}{sub-section:showFileOpenDialog_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:showFileOpenDialog_prs|text=|trigger=button}{sub-section}{sub-section:showFileOpenDialog_prs|trigger=none|class=sIndent}\[selectionMode(0=both,1=Files,2=Dirs)\]
\[startDirectory(null=default/previous)\]
\[multiselect(true/false)\]
\[filterarray\]
\[callbackmethod\]
\[dialog title text\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:showFileOpenDialog_ret|text=|trigger=button}{sub-section}{sub-section:showFileOpenDialog_ret|trigger=none|class=sIndent}[Object]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:showFileOpenDialog_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:showFileOpenDialog_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:showFileOpenDialog_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:showFileOpenDialog_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:showFileOpenDialog_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:showFileOpenDialog_sam|trigger=none}{code:language=javascript}
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
var file = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF","jpg","gif"));
application.output("you've selected file: " + file.getAbsolutePath());
//for the web you have to give a callback function that has a JSFile array as its first argument (also works in smart), other options can be set but are not used in the webclient (yet)
var file = plugins.file.showFileOpenDialog(myCallbackMethod)
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=showFileSaveDialog|class=node}{tr:id=name}{td}h6.showFileSaveDialog{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}showFileSaveDialog{span}{span:id=iets|style=float: left;}\(\[fileName/dir suggestion\], \[dialog title text\]){span}{td}{tr}{tr:id=des}{td}{sub-section:showFileSaveDialog_des|text=|trigger=button}{sub-section}{sub-section:showFileSaveDialog_des|trigger=none|class=sIndent}Shows a file save dialog.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:showFileSaveDialog_snc|text=|trigger=button}{sub-section}{sub-section:showFileSaveDialog_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:showFileSaveDialog_prs|text=|trigger=button}{sub-section}{sub-section:showFileSaveDialog_prs|trigger=none|class=sIndent}\[fileName/dir suggestion\]
\[dialog title text\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:showFileSaveDialog_ret|text=|trigger=button}{sub-section}{sub-section:showFileSaveDialog_ret|trigger=none|class=sIndent}[JSFile]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:showFileSaveDialog_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:showFileSaveDialog_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:showFileSaveDialog_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:showFileSaveDialog_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:showFileSaveDialog_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:showFileSaveDialog_sam|trigger=none}{code:language=javascript}
var file = plugins.file.showFileSaveDialog();
application.output("you've selected file: " + file.getAbsolutePath());
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=streamFilesFromServer|class=node}{tr:id=name}{td}h6.streamFilesFromServer{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}streamFilesFromServer{span}{span:id=iets|style=float: left;}\(file/fileName|fileArray/fileNameArray, serverFile/serverFileName|serverFileArray/serverFileNameArray, \[callbackFunction\]){span}{td}{tr}{tr:id=des}{td}{sub-section:streamFilesFromServer_des|text=|trigger=button}{sub-section}{sub-section:streamFilesFromServer_des|trigger=none|class=sIndent}Streams a file or an array of files from the server in a background task to a file (or files) on the client. If provided, calls back a Servoy function when done{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:streamFilesFromServer_snc|text=|trigger=button}{sub-section}{sub-section:streamFilesFromServer_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:streamFilesFromServer_prs|text=|trigger=button}{sub-section}{sub-section:streamFilesFromServer_prs|trigger=none|class=sIndent}file/fileName|fileArray/fileNameArray
serverFile/serverFileName|serverFileArray/serverFileNameArray
\[callbackFunction\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:streamFilesFromServer_ret|text=|trigger=button}{sub-section}{sub-section:streamFilesFromServer_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:streamFilesFromServer_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:streamFilesFromServer_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:streamFilesFromServer_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:streamFilesFromServer_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:streamFilesFromServer_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:streamFilesFromServer_sam|trigger=none}{code:language=javascript}
// transfer the first file of the default server folder to a chosen file on the client
var dir = plugins.file.getDesktopFolder();
var file = plugins.file.showFileSaveDialog(dir,'Save file to');
if (file) {
var list = plugins.file.getRemoteList('/', true);
if (list && list.length > 0) {
plugins.file.streamFilesFromServer(file, list[0], callbackFunction);
}
}
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=streamFilesToServer|class=node}{tr:id=name}{td}h6.streamFilesToServer{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}streamFilesToServer{span}{span:id=iets|style=float: left;}\(file/fileName|fileArray/fileNameArray, \[serverFile/serverFileName|serverFileArray/serverFileNameArray\], \[callbackFunction\]){span}{td}{tr}{tr:id=des}{td}{sub-section:streamFilesToServer_des|text=|trigger=button}{sub-section}{sub-section:streamFilesToServer_des|trigger=none|class=sIndent}Streams a file or an array of files to the server in a background task \- with optional relative path(s)/(new) name(s). If provided, calls back a Servoy function when done{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:streamFilesToServer_snc|text=|trigger=button}{sub-section}{sub-section:streamFilesToServer_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:streamFilesToServer_prs|text=|trigger=button}{sub-section}{sub-section:streamFilesToServer_prs|trigger=none|class=sIndent}file/fileName|fileArray/fileNameArray
\[serverFile/serverFileName|serverFileArray/serverFileNameArray\]
\[callbackFunction\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:streamFilesToServer_ret|text=|trigger=button}{sub-section}{sub-section:streamFilesToServer_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:streamFilesToServer_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:streamFilesToServer_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:streamFilesToServer_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:streamFilesToServer_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:streamFilesToServer_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:streamFilesToServer_sam|trigger=none}{code:language=javascript}
// send one file:
var file = plugins.file.showFileOpenDialog( 1, null, false, null, null, 'Choose a file to transfer' );
if (file) {
plugins.file.streamFilesToServer( file, callbackFunction );
}
// send an array of files:
var folder = plugins.file.showDirectorySelectDialog();
if (folder) {
var files = plugins.file.getFolderContents(folder);
if (files) {
plugins.file.streamFilesToServer( files, callbackFunction );
}
}
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=writeFile|class=node}{tr:id=name}{td}h6.writeFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}writeFile{span}{span:id=iets|style=float: left;}\(file, binary_data, \[mimeType\]){span}{td}{tr}{tr:id=des}{td}{sub-section:writeFile_des|text=|trigger=button}{sub-section}{sub-section:writeFile_des|trigger=none|class=sIndent}Writes data into a binary file. (Web Enabled){sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:writeFile_snc|text=|trigger=button}{sub-section}{sub-section:writeFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:writeFile_prs|text=|trigger=button}{sub-section}{sub-section:writeFile_prs|trigger=none|class=sIndent}file
binary_data
\[mimeType\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:writeFile_ret|text=|trigger=button}{sub-section}{sub-section:writeFile_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:writeFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:writeFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:writeFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:writeFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:writeFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:writeFile_sam|trigger=none}{code:language=javascript}
var bytes = new Array();
for (var i=0; i<1024; i++)
bytes[i] = i % 100;
var f = plugins.file.convertToJSFile('bin.dat');
if (!plugins.file.writeFile(f, bytes))
application.output('Failed to write the file.');
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
var mimeType = 'application/vnd.ms-excel'
if (!plugins.file.writeFile(f, bytes, mimeType))
application.output('Failed to write the file.');
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=writeTXTFile|class=node}{tr:id=name}{td}h6.writeTXTFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}writeTXTFile{span}{span:id=iets|style=float: left;}\(file, text_data, \[charsetname\], \[mimeType\]){span}{td}{tr}{tr:id=des}{td}{sub-section:writeTXTFile_des|text=|trigger=button}{sub-section}{sub-section:writeTXTFile_des|trigger=none|class=sIndent}Writes data into a text file. (Web Enabled){sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:writeTXTFile_snc|text=|trigger=button}{sub-section}{sub-section:writeTXTFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:writeTXTFile_prs|text=|trigger=button}{sub-section}{sub-section:writeTXTFile_prs|trigger=none|class=sIndent}file
text_data
\[charsetname\]
\[mimeType\]
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:writeTXTFile_ret|text=|trigger=button}{sub-section}{sub-section:writeTXTFile_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:writeTXTFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:writeTXTFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:writeTXTFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:writeTXTFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:writeTXTFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:writeTXTFile_sam|trigger=none}{code:language=javascript}
var fileNameSuggestion = 'myspecialexport.tab'
var textData = 'load of data...'
var success = plugins.file.writeTXTFile(fileNameSuggestion, textData);
if (!success) application.output('Could not write file.');
// For file-encoding parameter options (default OS encoding is used), http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| byte[] |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| readFile |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Reads all or part of the content from a binary file. If a file name is not specified, then a file selection dialog pops up for selecting a file. (Web Enabled) |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters [file] [size] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns byte[] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
// Read all content from the file.
var bytes = plugins.file.readFile('big.jpg');
application.output('file size: ' + bytes.length);
// Read only the first 1KB from the file.
var bytesPartial = plugins.file.readFile('big.jpg', 1024);
application.output('partial file size: ' + bytesPartial.length);
// Read all content from a file selected from the file open dialog.
var bytesUnknownFile = plugins.file.readFile();
application.output('unknown file size: ' + bytesUnknownFile.length);
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
readTXTFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| String |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| readTXTFile |
Span |
---|
| ([file], [charsetname]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Read all content from a text file. If a file name is not specified, then a file selection dialog pops up for selecting a file. The encoding can be also specified. (Web Enabled) |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters [file] [charsetname] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
// Read content from a known text file.
var txt = plugins.file.readTXTFile('story.txt');
application.output(txt);
// Read content from a text file selected from the file open dialog.
var txtUnknown = plugins.file.readTXTFile();
application.output(txtUnknown);
|
|
|
|
|
Table Body (tbody) |
---|
id | showDirectorySelectDialog |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
showDirectorySelectDialog |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| showDirectorySelectDialog |
Span |
---|
| ([directory suggestion], [dialog title text]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Shows a directory selector dialog. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters [directory suggestion] [dialog title text] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var dir = plugins.file.showDirectorySelectDialog();
application.output("you've selected folder: " + dir.getAbsolutePath());
|
|
|
|
|
Table Body (tbody) |
---|
id | showFileOpenDialog |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
showFileOpenDialog |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Object |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| showFileOpenDialog |
Span |
---|
| ([selectionMode(0=both,1=Files,2=Dirs)], [startDirectory(null=default/previous)], [multiselect(true/false)], [filterarray], [callbackmethod], [dialog title text]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled) |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters [selectionMode(0=both,1=Files,2=Dirs)] [startDirectory(null=default/previous)] [multiselect(true/false)] [filterarray] [callbackmethod] [dialog title text] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
var file = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF","jpg","gif"));
application.output("you've selected file: " + file.getAbsolutePath());
//for the web you have to give a callback function that has a JSFile array as its first argument (also works in smart), other options can be set but are not used in the webclient (yet)
var file = plugins.file.showFileOpenDialog(myCallbackMethod)
|
|
|
|
|
Table Body (tbody) |
---|
id | showFileSaveDialog |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
showFileSaveDialog |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| JSFile |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| showFileSaveDialog |
Span |
---|
| ([fileName/dir suggestion], [dialog title text]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Shows a file save dialog. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters [fileName/dir suggestion] [dialog title text] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var file = plugins.file.showFileSaveDialog();
application.output("you've selected file: " + file.getAbsolutePath());
|
|
|
|
|
Table Body (tbody) |
---|
id | streamFilesFromServer |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
streamFilesFromServer |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| void |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| streamFilesFromServer |
Span |
---|
| (file/fileName|fileArray/fileNameArray, serverFile/serverFileName|serverFileArray/serverFileNameArray, [callbackFunction]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Streams a file or an array of files from the server in a background task to a file (or files) on the client. If provided, calls back a Servoy function when done |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters file/fileName|fileArray/fileNameArray serverFile/serverFileName|serverFileArray/serverFileNameArray [callbackFunction] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns void |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
// transfer the first file of the default server folder to a chosen file on the client
var dir = plugins.file.getDesktopFolder();
var file = plugins.file.showFileSaveDialog(dir,'Save file to');
if (file) {
var list = plugins.file.getRemoteList('/', true);
if (list && list.length > 0) {
plugins.file.streamFilesFromServer(file, list[0], callbackFunction);
}
}
|
|
|
|
|
Table Body (tbody) |
---|
id | streamFilesToServer |
---|
class | node |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
streamFilesToServer |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| void |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| streamFilesToServer |
Span |
---|
| (file/fileName|fileArray/fileNameArray, [serverFile/serverFileName|serverFileArray/serverFileNameArray], [callbackFunction]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Streams a file or an array of files to the server in a background task - with optional relative path(s)/(new) name(s). If provided, calls back a Servoy function when done |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters file/fileName|fileArray/fileNameArray [serverFile/serverFileName|serverFileArray/serverFileNameArray] [callbackFunction] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns void |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
// send one file:
var file = plugins.file.showFileOpenDialog( 1, null, false, null, null, 'Choose a file to transfer' );
if (file) {
plugins.file.streamFilesToServer( file, callbackFunction );
}
// send an array of files:
var folder = plugins.file.showDirectorySelectDialog();
if (folder) {
var files = plugins.file.getFolderContents(folder);
if (files) {
plugins.file.streamFilesToServer( files, callbackFunction );
}
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Boolean |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| writeFile |
Span |
---|
| (file, binary_data, [mimeType]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Writes data into a binary file. (Web Enabled) |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters file binary_data [mimeType] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var bytes = new Array();
for (var i=0; i<1024; i++)
bytes[i] = i % 100;
var f = plugins.file.convertToJSFile('bin.dat');
if (!plugins.file.writeFile(f, bytes))
application.output('Failed to write the file.');
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
|
|
|
|
| {code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=writeXMLFile|class=node}{tr:id=name}{td}h6.writeXMLFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}writeXMLFile{span}{span:id=iets|style=float: left;}\(file, xml_data){span}{td}{tr}{tr:id=des}{td}{sub-section:writeXMLFile_des|text=|trigger=button}{sub-section}{sub-section:writeXMLFile_des|trigger=none|class=sIndent}Writes data into an XML file. The file is saved with the encoding specified by the XML itself. (Web Enabled){sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:writeXMLFile_snc|text=|trigger=button}{sub-section}{sub-section:writeXMLFile_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:writeXMLFile_prs|text=|trigger=button}{sub-section}{sub-section:writeXMLFile_prs|trigger=none|class=sIndent}file
xml_data
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:writeXMLFile_ret|text=|trigger=button}{sub-section}{sub-section:writeXMLFile_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:writeXMLFile_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:writeXMLFile_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:writeXMLFile_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:writeXMLFile_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:writeXMLFile_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:writeXMLFile_sam|trigger=none}{code:language=javascript} var mimeType = 'application/vnd.ms-excel'
if (!plugins.file.writeFile(f, bytes, mimeType))
application.output('Failed to write the file.');
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
writeTXTFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Boolean |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| writeTXTFile |
Span |
---|
| (file, text_data, [charsetname], [mimeType]) |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Writes data into a text file. (Web Enabled) |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters file text_data [charsetname] [mimeType] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var fileNameSuggestion = 'myspecialexport.tab'
var textData = 'load of data...'
var success = plugins.file.writeTXTFile(fileNameSuggestion, textData);
if (!success) application.output('Could not write file.');
// For file-encoding parameter options (default OS encoding is used), http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
writeXMLFile |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Boolean |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| writeXMLFile |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Writes data into an XML file. The file is saved with the encoding specified by the XML itself. (Web Enabled) |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters file xml_data |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
var fileName = 'form.xml'
var xml = controller.printXML()
var success = plugins.file.writeXMLFile(fileName, xml);
if (!success) application.output('Could not write file.');
|
|
|
|
| {code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table} |