summaryrefslogtreecommitdiffstats
path: root/helpcontent2/source/text/sbasic/shared/03/sf_filesystem.xhp
diff options
context:
space:
mode:
Diffstat (limited to 'helpcontent2/source/text/sbasic/shared/03/sf_filesystem.xhp')
-rw-r--r--helpcontent2/source/text/sbasic/shared/03/sf_filesystem.xhp1129
1 files changed, 1129 insertions, 0 deletions
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_filesystem.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_filesystem.xhp
new file mode 100644
index 000000000..9461b7604
--- /dev/null
+++ b/helpcontent2/source/text/sbasic/shared/03/sf_filesystem.xhp
@@ -0,0 +1,1129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<helpdocument version="1.0">
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+
+<meta>
+ <topic id="SF_FileSystem" indexer="include" status="PUBLISH">
+ <title id="tit" xml-lang="en-US">ScriptForge.FileSystem service</title>
+ <filename>/text/sbasic/shared/03/sf_filesystem.xhp</filename>
+ </topic>
+</meta>
+
+<body>
+<section id="ScriptForge-sf_filesystem">
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id41582391760252">
+ <bookmark_value>FileSystem service</bookmark_value>
+ </bookmark>
+</section>
+
+<section id="abstract">
+ <h1 id="bm_id781582391760253" xml-lang="en-US"><variable id="FileSystemService"><link href="text/sbasic/shared/03/sf_filesystem.xhp" name="FileSystem service"><literal>ScriptForge</literal>.<literal>FileSystem</literal> service</link></variable></h1>
+ <paragraph role="paragraph" id="par_id931583589764919" xml-lang="en-US">The <literal>FileSystem</literal> service includes routines to handle files and folders. Next are some examples of the features provided by this service:</paragraph>
+ <list type="unordered">
+ <listitem>
+ <paragraph id="par_id121612917070593" role="listitem">Verify whether a file or folder exists.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id121612917070594" role="listitem">Create and delete folders and files.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id121612917070595" role="listitem">Launch dialog boxes to open/save files.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id121612917070596" role="listitem">Access the list of files in a folder, etc.</paragraph>
+ </listitem>
+ </list>
+</section>
+ <note id="par_id121612917368946">The methods in the FileSystem service are mostly based on the <link href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1ucb_1_1XSimpleFileAccess.html" name="XSimpleFileAccess API"><literal>XSimpleFileAccess</literal> UNO interface.</link></note>
+
+ <h2 id="hd_id961583589783025" xml-lang="en-US">Definitions</h2>
+ <paragraph role="paragraph" id="par_id821612988815351">The table below lists the main parameters used by most of the methods in the <literal>FileSystem</literal> service.</paragraph>
+ <table id="tab_id721612988600163">
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id891612988600163" role="tablehead">Parameter</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id711612988600163" role="tablehead">Description</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id181612988600163" role="tablecontent" localize="false"><literal>FileName</literal></paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id321612988600163" role="tablecontent">The full name of the file including the path without a path separator at the end.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id181612988600164" role="tablecontent" localize="false"><literal>FolderName</literal></paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id321612988600165" role="tablecontent">The full name of the folder including the path. It may or may not contain the ending path separator.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id181612988600166" role="tablecontent" localize="false"><literal>Name</literal></paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id321612988600167" role="tablecontent">The last component of the <emph>Folder Name</emph> or <emph>File Name</emph> including its extension. This parameter is always expressed using the native format of the operating system.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id181612988600168" role="tablecontent" localize="false"><literal>BaseName</literal></paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id321612988600169" role="tablecontent">The last component of the <emph>Folder Name</emph> or <emph>File Name</emph> without its extension.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id181612988600171" role="tablecontent" localize="false"><literal>NamePattern</literal></paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id321612988600172" role="tablecontent">Any of the above names containing wildcards in its last component. Admitted wildcards are:</paragraph>
+ <list type="unordered">
+ <listitem>
+ <paragraph id="par_id851583590809104" role="listitem" xml-lang="en-US">"?" represents any single character</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id161583590819320" role="listitem" xml-lang="en-US">"*" represents zero, one, or multiple characters</paragraph>
+ </listitem>
+ </list>
+ </tablecell>
+ </tablerow>
+ </table>
+ <tip id="par_id911584540527980" xml-lang="en-US">The <literal>FileSystem</literal> service allows to perform operations over multiple files at the same time. By using name patterns, user scripts can copy, move or delete multiple files. Conversely, Basic built-in methods can only handle single files.</tip>
+
+ <h3 id="hd_id991612918109871">File Naming Notation</h3>
+ <paragraph role="paragraph" id="par_id791612918141083">The notation used to express file and folder names, both for arguments and returned values, is defined by the <literal>FileNaming</literal> property of the <literal>FileSystem</literal> service.</paragraph>
+ <paragraph role="paragraph" id="par_id951612918220255">In short, the possible representation types are "URL" (URL file notation), "SYS" (operating system notation) and "ANY" (default). See more information <link href="text/sbasic/shared/03/sf_filesystem.xhp#properties" name="Properties Table">below</link>.</paragraph>
+ <tip id="par_id861583589907100" xml-lang="en-US">An example of the URL notation is <emph>file:///C:/Documents/my_file.odt</emph>. Whenever possible consider using the URL notation because it is a more portable alternative.</tip>
+ <warning id="par_id931626652451855">The use of the shortcut "~" (tilde), which is common in Linux-based operating systems, is not supported to express a path to a folder and file name. Instead of using <emph>"~/Documents/my_file.odt"</emph> use the full path <emph>"/home/user/Documents/my_file.odt"</emph>.</warning>
+
+ <h2 id="hd_id581582885621841" xml-lang="en-US">Service invocation</h2>
+ <paragraph role="paragraph" id="par_id691612990276070">The following code snippet invokes the <literal>FileSystem</literal> service. The method <literal>BuildPath</literal> was used as an example.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id551610734764343">GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id371582885621964">Dim FSO As Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id201582885621287">Set FSO = CreateScriptService("FileSystem")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id901612990364784">FSO.BuildPath(...)</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id301626147154020">from scriptforge import CreateScriptService</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id771626147154696">fs = CreateScriptService("FileSystem")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id741626147154953">fs.BuildPath(...)</paragraph>
+ </pycode>
+
+ <bookmark xml-lang="en-US" branch="index" id="bm_id901612991354326" localize="false">
+ <bookmark_value>FileSystem service;FileNaming property</bookmark_value>
+ <bookmark_value>FileSystem service;ConfigFolder property</bookmark_value>
+ <bookmark_value>FileSystem service;ExtensionsFolder property</bookmark_value>
+ <bookmark_value>FileSystem service;HomeFolder property</bookmark_value>
+ <bookmark_value>FileSystem service;InstallFolder property</bookmark_value>
+ <bookmark_value>FileSystem service;TemplatesFolder property</bookmark_value>
+ <bookmark_value>FileSystem service;TemporaryFolder property</bookmark_value>
+ <bookmark_value>FileSystem service;UserTemplatesFolder property</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id651583668365757" xml-lang="en-US">Properties</h2>
+ <section id="properties">
+ <table id="tab_id381583668386455">
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id871583668386455" role="tablehead" xml-lang="en-US">Name</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id491583668386455" role="tablehead" xml-lang="en-US">Readonly</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id271583668474014" role="tablehead" xml-lang="en-US">Type</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id401583668386455" role="tablehead" xml-lang="en-US">Description</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id151583668386455" role="tablecontent" xml-lang="en-US" localize="false">FileNaming</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id371583668519172" role="tablecontent" xml-lang="en-US">No</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id271583668386455" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id771583668386455" role="tablecontent" xml-lang="en-US">Sets or returns the current files and folders notation, either "ANY", "URL" or "SYS":</paragraph>
+ <list type="unordered">
+ <listitem>
+ <paragraph role="paragraph" id="par_id881585396501844" xml-lang="en-US"><emph>"ANY"</emph>: (default) the methods of the <literal>FileSystem</literal> service accept both URL and current operating system's notation for input arguments but always return URL strings.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph role="paragraph" id="par_id261583669091722" xml-lang="en-US"><emph>"URL"</emph>: the methods of the <literal>FileSystem</literal> service expect URL notation for input arguments and return URL strings.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph role="paragraph" id="par_id731583669120436" xml-lang="en-US"><emph>"SYS"</emph>: the methods of the <literal>FileSystem</literal> service expect current operating system's notation for both input arguments and return strings.</paragraph>
+ </listitem>
+ </list>
+ <paragraph role="paragraph" id="par_id211583765169579" xml-lang="en-US">Once set, the <literal>FileNaming</literal> property remains unchanged either until the end of the %PRODUCTNAME session or until it is set again.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id951583839708571" role="tablecontent" xml-lang="en-US" localize="false">ConfigFolder</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id541583839708548" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id751583839708362" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id731583839708412" role="tablecontent" xml-lang="en-US">Returns the configuration folder of %PRODUCTNAME.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id511584027709311" role="tablecontent" xml-lang="en-US" localize="false">ExtensionsFolder</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id761584027709516" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id491584027709825" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id971584027709752" role="tablecontent" xml-lang="en-US">Returns the folder where extensions are installed.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id491583839767611" role="tablecontent" xml-lang="en-US" localize="false">HomeFolder</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id31583839767743" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id741583839767926" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id111583839767195" role="tablecontent" xml-lang="en-US">Returns the user home folder.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id83158383992056" role="tablecontent" xml-lang="en-US" localize="false">InstallFolder</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id771583839920487" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id971583839920282" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id451583839920858" role="tablecontent" xml-lang="en-US">Returns the installation folder of %PRODUCTNAME.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id751588333908795" role="tablecontent" xml-lang="en-US" localize="false">TemplatesFolder</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id571588333908716" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id781588333908500" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id721588333908708" role="tablecontent" xml-lang="en-US">Returns the folder containing the system templates files.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id251583774433989" role="tablecontent" xml-lang="en-US" localize="false">TemporaryFolder</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id501583774433513" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id411583774433779" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id71583774433459" role="tablecontent" xml-lang="en-US">Returns the temporary files folder defined in the %PRODUCTNAME path settings.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id731588334016220" role="tablecontent" xml-lang="en-US" localize="false">UserTemplatesFolder</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id271588334016191" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id991588334016273" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id251588334016874" role="tablecontent" xml-lang="en-US">Returns the folder containing the user-defined template files.</paragraph>
+ </tablecell>
+ </tablerow>
+ </table>
+ </section>
+
+<table id="tab_id501611613601554">
+ <tablerow>
+ <tablecell colspan="3"><paragraph id="par_id891611613601554" role="tablehead">List of Methods in the FileSystem Service</paragraph></tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id891611613601556" role="tablecontent" localize="false">
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#BuildPath" name="BuildPath method">BuildPath</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#CompareFiles" name="CompareFiles method">CompareFiles</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#CopyFile" name="CopyFile method">CopyFile</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#CopyFolder" name="CopyFolder method">CopyFolder</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#CreateFolder" name="CreateFolder method">CreateFolder</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#CreateTextFile" name="CreateTextFile method">CreateTextFile</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#DeleteFile" name="DeleteFile method">DeleteFile</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#DeleteFolder" name="DeleteFolder method">DeleteFolder</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#ExtensionFolder" name="ExtensionFolder method">ExtensionFolder</link><br/>
+ </paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id541611613601554" role="tablecontent" localize="false">
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#FileExists" name="FileExists method">FileExists</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#Files" name="Files method">Files</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#FolderExists" name="FolderExists method">FolderExists</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#GetBaseName" name="GetBaseName method">GetBaseName</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#GetExtension" name="GetExtension method">GetExtension</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#GetFileLen" name="GetFileLen method">GetFileLen</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#GetFileModified" name="GetFileModified method">GetFileModified</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#GetName" name="GetName method">GetName</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#GetParentFolderName" name="GetParentFolderName method">GetParentFolderName</link><br/>
+ </paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id701611613601554" role="tablecontent" localize="false">
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#GetTempName" name="GetTempName method">GetTempName</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#HashFile" name="HashFile method">HashFile</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#MoveFile" name="MoveFile method">MoveFile</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#MoveFolder" name="MoveFolder method">MoveFolder</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#OpenTextFile" name="OpenTextFile method">OpenTextFile</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#PickFile" name="PickFile method">PickFile</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#PickFolder" name="PickFolder method">PickFolder</link><br/>
+ <link href="text/sbasic/shared/03/sf_filesystem.xhp#SubFolders" name="SubFolders method">SubFolders</link><br/><br/>
+ </paragraph>
+ </tablecell>
+ </tablerow>
+</table>
+
+<section id="BuildPath">
+ <comment> BuildPath ----------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id721583933076548">
+ <bookmark_value>FileSystem service;BuildPath</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id681583933076692" localize="false">BuildPath</h2>
+ <paragraph role="paragraph" id="par_id871583933076448">Joins a folder path and the name of a file and returns the full file name with a valid path separator. The path separator is added only if necessary.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id251626147640389">
+ <input>svc.BuildPath(foldername: str, name: str): str</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id90158393307695"><emph>foldername</emph>: The path with which <literal>name</literal> will be combined. The specified path does not need to be an existing folder.</paragraph>
+ <paragraph role="paragraph" id="par_id891583933076975"><emph>name</emph>: The name of the file to be appended to <literal>foldername</literal>. This parameter uses the notation of the current operating system.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id571583933076688">Dim FSO as Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id891626278435709">Set FSO = CreateScriptService("FileSystem")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id771626215559964">Dim aFileName as String</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id271583933076624">FSO.FileNaming = "URL"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id531583933076390">aFileName = FSO.BuildPath("file:///home/user", "sample file.odt")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id591583933645158">' file:///home/user/sample%20file.odt</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id811626215598688">fs = CreateScriptService("FileSystem")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id951626215599055">fs.FileNaming = "URL"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id151626215599287">aFileName = fs.BuildPath("file:///home/user", "sample file.odt")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id731626215599407"># file:///home/user/sample%20file.odt</paragraph>
+ </pycode>
+</section>
+
+<section id="CompareFiles">
+ <comment> CompareFiles ----------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id141601118910914">
+ <bookmark_value>FileSystem service;CompareFiles</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id441601118910655" localize="false">CompareFiles</h2>
+ <paragraph role="paragraph" id="par_id33160111891079">Compares two files and returns <literal>True</literal> when they seem identical.</paragraph>
+ <paragraph role="paragraph" id="par_id631601119001315" xml-lang="en-US">Depending on the value of the <literal>comparecontents</literal> argument, the comparison between both files can be either based only on file attributes (such as the last modified date), or based on the file contents.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id61626148854349">
+ <input>svc.CompareFiles(filename1: str, filename2: str, comparecontents: bool = False): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id481601118910755"><emph>filename1, filename2</emph>: The files to compare.</paragraph>
+ <paragraph role="paragraph" id="par_id111601118910848" xml-lang="en-US"><emph>comparecontents</emph>: When <literal>True</literal>, the contents of the files are compared (default = <literal>False</literal>).</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id231601118910666">FSO.FileNaming = "SYS"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id101601118910778">If FSO.CompareFiles("C:\myFile1.txt", "C:\myFile2.txt", CompareContents := False) Then</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id171601123413866"> ' ...</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id271612997571657">End If</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id341626215746128">fs.FileNaming = "SYS"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id141626215746355">if fs.CompareFiles(r"C:\myFile1.txt", r"C:\myFile2.txt", comparecontents = False):</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id111626215746495"> # ...</paragraph>
+ </pycode>
+</section>
+
+<section id="CopyFile">
+ <comment> CopyFile ---------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id41584541257826">
+ <bookmark_value>FileSystem service;CopyFile</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id95158454125767" localize="false">CopyFile</h2>
+ <paragraph role="paragraph" id="par_id161584541257982">Copies one or more files from one location to another. Returns <literal>True</literal> if at least one file has been copied or <literal>False</literal> if an error occurred.</paragraph>
+ <paragraph role="paragraph" id="par_id401612998805699">An error will also occur if the <literal>source</literal> parameter uses wildcard characters and does not match any files.</paragraph>
+ <paragraph role="paragraph" id="par_id331612998814805">The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id611626148998301">
+ <input>svc.CopyFile(source: str, destination: str, overwrite: bool = True): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id1001584541257789"><emph>source</emph>: It can be a <literal>FileName</literal> or a <literal>NamePattern</literal> indicating one or more files to be copied.</paragraph>
+ <paragraph role="paragraph" id="par_id111584542310166" xml-lang="en-US"><emph>destination</emph>: It can be either a <literal>FileName</literal> specifying where the single <literal>source</literal> file is to be copied, or a <literal>FolderName</literal> into which the multiple files from <literal>source</literal> are to be copied.</paragraph>
+ <list type="unordered">
+ <listitem>
+ <paragraph role="paragraph" id="par_id491612999134752">If <literal>destination</literal> does not exist, it is created.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph role="paragraph" id="par_id591612999166788">Wildcard characters are not allowed in <literal>destination</literal>.</paragraph>
+ </listitem>
+ </list>
+ <paragraph role="paragraph" id="par_id251584542431558" xml-lang="en-US"><emph>overwrite</emph>: If <literal>True</literal> (default), files may be overwritten. The method will fail if <literal>destination</literal> is readonly, regardless of the value specified in <literal>overwrite</literal>.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <paragraph role="paragraph" id="par_id691626216252568">In the examples below the first line copies a single file whereas the second line copies multiple files using wildcards.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id851613000918341">FSO.CopyFile("C:\Documents\my_file.odt", "C:\Temp\copied_file.odt")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id501584541257221">FSO.CopyFile("C:\Documents\*.*", "C:\Temp\", Overwrite := False)</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id471626216422324">fs.CopyFile(r"C:\Documents\my_file.odt", r"C:\Temp\copied_file.odt")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id141626216422517">fs.CopyFile(r"C:\Documents\*.*", r"C:\Temp", overwrite = False)</paragraph>
+ </pycode>
+ <note id="par_id411626216328023">Beware that subfolders and their contents are not copied when wildcards are used in the <emph>source</emph> argument.</note>
+</section>
+
+<section id="CopyFolder">
+ <comment> CopyFolder ----------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id661584544734386">
+ <bookmark_value>FileSystem service;CopyFolder</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id201584544734113" localize="false">CopyFolder</h2>
+ <paragraph role="paragraph" id="par_id731584544734412">Copies one or more folders from one location to another. Returns <literal>True</literal> if at least one folder has been copied or <literal>False</literal> if an error occurred.</paragraph>
+ <paragraph role="paragraph" id="par_id21612999775377">An error will also occur if the <literal>source</literal> parameter uses wildcard characters and does not match any folders.</paragraph>
+ <paragraph role="paragraph" id="par_id701612999808912">The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id381626149136823">
+ <input>svc.CopyFolder(source: str, destination: str, overwrite: bool = True): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id851584544734202"><emph>source</emph>: It can be a <literal>FolderName</literal> or a <literal>NamePattern</literal> indicating one or more folders to be copied.</paragraph>
+ <paragraph role="paragraph" id="par_id321584544734273" xml-lang="en-US"><emph>destination</emph>: Specifies the <literal>FolderName</literal> into which the single or multiple folders defined in <literal>source</literal> are to be copied.</paragraph>
+ <list type="unordered">
+ <listitem>
+ <paragraph role="paragraph" id="par_id491612999134762">If <literal>destination</literal> does not exist, it is created.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph role="paragraph" id="par_id591612999166740">Wildcard characters are not allowed in <literal>destination</literal>.</paragraph>
+ </listitem>
+ </list>
+ <paragraph role="paragraph" id="par_id251584542431525" xml-lang="en-US"><emph>overwrite</emph>: If <literal>True</literal> (default), files may be overwritten. The method will fail if <literal>destination</literal> is readonly, regardless of the value specified in <literal>overwrite</literal>.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <paragraph role="paragraph" id="par_id751626216627481">In the examples below all files, folders and subfolders are copied.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id761584882338442">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id651584544734985">FSO.CopyFolder("C:\Documents\*", "C:\Temp\", Overwrite := False)</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id431626216707056"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id771626216707454">fs.CopyFolder(r"C:\Documents\*", r"C:\Temp", overwrite = False)</paragraph>
+ </pycode>
+</section>
+
+<section id="CreateFolder">
+ <comment> CreateFolder -------------------------------------------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id95158454067521">
+ <bookmark_value>FileSystem service;CreateFolder</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id501584540675285" localize="false">CreateFolder</h2>
+ <paragraph role="paragraph" id="par_id31158454067562">Creates the specified <literal>FolderName</literal>. Returns <literal>True</literal> if the folder could be successfully created.</paragraph>
+ <paragraph role="paragraph" id="par_id431613000475359">If the specified folder has a parent folder that does not exist, it is created.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id531626177201641">
+ <input>svc.CreateFolder(foldername: str): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id491584540675469"><emph>foldername</emph>: A string representing the folder to be created. If the folder already exists, an exception will be raised.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id441584540675381">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id491584540675179">FSO.CreateFolder("C:\NewFolder")</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id971626216947436"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id181626216947810">fs.CreateFolder(r"C:\NewFolder")</paragraph>
+ </pycode>
+</section>
+
+<section id="CreateTextFile">
+ <comment> CreateTextFile ------------------------------------------------------------------------------ </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id651585322689546">
+ <bookmark_value>FolderSystem service;CreateTextFile</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id19158532268911" localize="false">CreateTextFile</h2>
+ <paragraph role="paragraph" id="par_id731585322689518">Creates a specified file and returns a <literal>TextStream</literal> service instance that can be used to write to the file.</paragraph>
+ <paragraph role="paragraph" id="par_id821613001057759">The method returns a <literal>Null</literal> object if an error occurred.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id431626178025633">
+ <input>svc.CreateTextFile(filename: str, overwrite: bool = True, encoding: str = 'UTF-8'): svc</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id901585322689715"><emph>filename</emph>: The name of the file to be created.</paragraph>
+ <paragraph role="paragraph" id="par_id501585322689209"><emph>overwrite</emph>: Boolean value that determines if <literal>filename</literal> can be overwritten (default = <literal>True</literal>).</paragraph>
+ <paragraph role="paragraph" id="par_id551585322689192"><emph>encoding</emph>: The character set to be used. The default encoding is "UTF-8".</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id291585322689770">Dim myFile As Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id541585322689351">FSO.FileNaming = "SYS"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id51585322689982">Set myFile = FSO.CreateTextFile("C:\Temp\ThisFile.txt", Overwrite := True)</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id291626217084462">fs.FileNaming = "SYS"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id251626217084848">myFile = fs.CreateTextFile(r"C:\Temp\ThisFile.txt", overwrite = True)</paragraph>
+ </pycode>
+ <note id="par_id141613001281573">To learn more about the names of character sets, visit <link href="https://www.iana.org/assignments/character-sets/character-sets.xhtml" name="Character Sets">IANA's Character Set</link> page. Beware that %PRODUCTNAME does not implement all existing character sets.</note>
+</section>
+
+<section id="DeleteFile">
+ <comment> DeleteFile -------------------------------------------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id421584882040621">
+ <bookmark_value>FileSystem service;DeleteFile</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id191584882040749" localize="false">DeleteFile</h2>
+ <paragraph role="paragraph" id="par_id11584882040881">Deletes one or more files. Returns <literal>True</literal> if at least one file has been deleted or <literal>False</literal> if an error occurred.</paragraph>
+ <paragraph role="paragraph" id="par_id21612999775356">An error will also occur if the <literal>filename</literal> parameter uses wildcard characters and does not match any files.</paragraph>
+ <paragraph role="paragraph" id="par_id21613001848493">The files to be deleted must not be readonly.</paragraph>
+ <paragraph role="paragraph" id="par_id701612999808832">The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id11626178195995">
+ <input>svc.DeleteFile(filename: str): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id441584882040860"><emph>filename</emph>: It can be a <literal>FileName</literal> or a <literal>NamePattern</literal> indicating one or more files to be deleted.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <paragraph role="paragraph" id="par_id851626217167909">In the examples below only files are deleted, subfolders are not deleted.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id321584882040274">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id501584882040356">FSO.DeleteFile("C:\Temp\*.docx")</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id41626217239069"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id491626217239297">fs.DeleteFile(r"C:\Temp\*.docx")</paragraph>
+ </pycode>
+</section>
+
+<section id="DeleteFolder">
+ <comment> DeleteFolder -------------------------------------------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id91584882542710">
+ <bookmark_value>FileSystem service;DeleteFolder</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id151584882542309" localize="false">DeleteFolder</h2>
+ <paragraph role="paragraph" id="par_id11584882015881">Deletes one or more folders. Returns <literal>True</literal> if at least one folder has been deleted or <literal>False</literal> if an error occurred.</paragraph>
+ <paragraph role="paragraph" id="par_id21612999775346">An error will also occur if the <literal>foldername</literal> parameter uses wildcard characters and does not match any folders.</paragraph>
+ <paragraph role="paragraph" id="par_id21613001848853">The folders to be deleted must not be readonly.</paragraph>
+ <paragraph role="paragraph" id="par_id701612999808842">The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id61626178267917">
+ <input>svc.DeleteFolder(foldername: str): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id451584882542247"><emph>foldername</emph>: It can be a <literal>FolderName</literal> or a <literal>NamePattern</literal> indicating one or more folders to be deleted.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <paragraph role="paragraph" id="par_id651626217314709">In the examples below only folders and their contents are deleted. Files in the parent folder "C:\Temp" are not deleted.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id751584882542695">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id611584882542154">FSO.DeleteFolder("C:\Temp\*")</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id441626217397570"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id371626217398060">fs.DeleteFolder(r"C:\Temp\*")</paragraph>
+ </pycode>
+</section>
+
+<section id="ExtensionFolder">
+ <comment> ExtensionFolder --------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id91584882542365">
+ <bookmark_value>FileSystem service;ExtensionFolder</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id151584882542104" localize="false">ExtensionFolder</h2>
+ <paragraph role="paragraph" id="par_id11584882015025">Returns a string containing the folder where the specified extension package is installed.</paragraph>
+ <paragraph role="paragraph" id="par_id21612999775311">The current value of the property <literal>SF_FileSystem.FileNaming</literal> is used to determine the notation of the returned string.</paragraph>
+ <tip id="par_id891644442917193">Use the property <link href="text/sbasic/shared/03/sf_platform.xhp#hd_id711600788076834" name="Extensions_link"><literal>Extensions</literal></link> from the <literal>Platform</literal> service to get string array with the IDs of all installed extensions.</tip>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id61626178211365">
+ <input>svc.ExtensionFolder(extension: str): str</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id451584882542121"><emph>extension</emph>: A string value with the ID of the extension. If the extension is not installed, an exception is raised.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <paragraph role="paragraph" id="par_id651626217313369">The examples below in Basic and Python return the folder where the APSO extension is installed.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id116444434113410">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id751584882540355">sFolder = FSO.ExtensionFolder("apso.python.script.organizer")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id611584882542269">' file:///home/username/.config/libreoffice/4/user/uno_packages/cache/uno_packages/lu10833wz3u2i.tmp_/apso_1_2_7.oxt</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id441626217397588"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id371626217398166">sFolder = fs.ExtensionFolder("apso.python.script.organizer")</paragraph>
+ </pycode>
+</section>
+
+<section id="FileExists">
+ <comment> FileExists --------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id571583764426508">
+ <bookmark_value>FileSystem service;FileExists</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id39158376442641" localize="false">FileExists</h2>
+ <paragraph role="paragraph" id="par_id161583764426709">Returns <literal>True</literal> if a given file name is valid and exists, otherwise the method returns <literal>False</literal>.</paragraph>
+ <paragraph role="paragraph" id="par_id91613003122613">If the <literal>filename</literal> parameter is actually an existing folder name, the method returns <literal>False</literal>.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id201626178344527">
+ <input>svc.FileExists(filename: str): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id361583764426547"><emph>filename</emph>: A string representing the file to be tested.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id621583764787755">FSO.FileNaming = "SYS"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id821583764426197">If FSO.FileExists("C:\Documents\my_file.odt") Then</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id191613003283635"> '...</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id891613003291580">End If</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id551626270512839">fs.FileNaming = "SYS"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id411626270513159">if fs.FileExists(r"C:\Documents\my_file.odt"):</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id591626270513425"> # ...</paragraph>
+ </pycode>
+</section>
+
+<section id="Files">
+ <comment> Files ------------------------------------------------------------------------------------------ </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id771583944327771">
+ <bookmark_value>FileSystem service;Files</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id461583944327647" localize="false">Files</h2>
+ <paragraph role="paragraph" id="par_id11158394432779">Returns a zero-based array of the files stored in a given folder. Each entry in the array is a string containing the full path and file name.</paragraph>
+ <paragraph role="paragraph" id="par_id641613003790120">If the argument <literal>foldername</literal> specifies a folder that does not exist, an exception is raised.</paragraph>
+ <paragraph role="paragraph" id="par_id821613003779799">The resulting list may be filtered with wildcards.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id211626178396995">
+ <input>svc.Files(foldername: str, filter: str = ''): str[0..*]</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id731583944543140"><emph>foldername</emph>: A string representing a folder. The folder must exist. This argument must not designate a file.</paragraph>
+ <paragraph role="paragraph" id="par_id591585648450060" xml-lang="en-US"><emph>filter</emph>: A string containing wildcards ("?" and "*") that will be applied to the resulting list of files (default = "").</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id381583944327923">Dim filesList As Variant, file As String</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id581583944327968">FSO.FileNaming = "SYS"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id451583944327508">filesList = FSO.Files("/home/user/", "*.txt")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id521583944732086">For Each file In filesList</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id421583944743304"> ' ...</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id721583944748672">Next file</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id811626270625785">fs.FileNaming = "SYS"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id761626270626093">filesList = fs.Files("/home/user/", "*.txt")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id381626270626357">for file in fileList:</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id941626270626838"> # ...</paragraph>
+ </pycode>
+</section>
+
+<section id="FolderExists">
+ <comment> FolderExists -------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id11583765642643">
+ <bookmark_value>FileSystem service;FolderExists</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id421583765642360" localize="false">FolderExists</h2>
+ <paragraph role="paragraph" id="par_id51583765642590">Returns <literal>True</literal> if the specified <literal>FolderName</literal> is valid and exists, otherwise the method returns <literal>False</literal>.</paragraph>
+ <paragraph role="paragraph" id="par_id151613004111990">If the <literal>foldername</literal> parameter is actually an existing file name, the method returns <literal>False</literal>.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id451626270785443">
+ <input>svc.FolderExists(foldername: str): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id1001583765642211"><emph>foldername</emph>: A string representing the folder to be tested.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id301583765642138">FSO.FileNaming = "SYS"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id771583765642330">If FSO.FolderExists("C:\Documents\Thesis") Then</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id21613004201438"> '...</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id861613004206334">End If</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id761626270831628">fs.FileNaming = "SYS"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id531626270831916">if fs.FolderExists(r"C:\Documents\Thesis")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id801626270832082"> # ...</paragraph>
+ </pycode>
+</section>
+
+<section id="GetBaseName">
+ <comment> GetBaseName ---------------------------------------------------------------------------------------</comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id54158411061866">
+ <bookmark_value>FileSystem service;GetBaseName</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id111584110618587" localize="false">GetBaseName</h2>
+ <paragraph role="paragraph" id="par_id521584110618989">Returns the <literal>BaseName</literal> (equal to the last component) of a folder or file name, without its extension.</paragraph>
+ <paragraph role="paragraph" id="par_id731613004316790">The method does not check if the specified file or folder exists.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id301626178954105">
+ <input>svc.GetBaseName(filename: str): str</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id691584110618308"><emph>filename</emph>: A string representing the file name and its path.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <paragraph role="paragraph" id="par_id1001626271201609">In the examples below, the first <literal>GetBaseName</literal> method call corresponds to a folder, so the function returns the last component of the path. The second call receives a file name as input, so the name of the file is returned without its extension.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id201584110618266">MsgBox FSO.GetBaseName("/home/user/Documents") ' "Documents"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id211584110618884">MsgBox FSO.GetBaseName("/home/user/Documents/my_file.ods") ' "my_file"</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id431626271314848">bas = CreateScriptService("Basic")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id411626271315092">bas.MsgBox(fs.GetBaseName("/home/user/Documents")) # "Documents"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id821626271315317">bas.MsgBox(fs.GetBaseName("/home/user/Documents/my_file.ods")) # "my_file"</paragraph>
+ </pycode>
+</section>
+
+<section id="GetExtension">
+ <comment> GetExtension ------------------------------------------------------------------------------------ </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id271584032680645">
+ <bookmark_value>FileSystem service;GetExtension</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id441584032680932" localize="false">GetExtension</h2>
+ <paragraph role="paragraph" id="par_id831584032680866">Returns the extension part of a file or folder name without the dot "." character.</paragraph>
+ <paragraph role="paragraph" id="par_id941613060736524">The method does not check for the existence of the specified file or folder.</paragraph>
+ <paragraph role="paragraph" id="par_id561613060896361">If this method is applied to a folder name or to a file without an extension, then an empty string is returned.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id481626179171535">
+ <input>svc.GetExtension(filename: str): str</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id821584032680311"><emph>filename</emph>: A string representing the file name and its path.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id241584032680600">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id651584032680887">ext = FSO.GetExtension("C:\Windows\Notepad.exe") ' "exe"</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id391626271533012"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id751626271533408">ext = fs.GetExtension(r"C:\Windows\Notepad.exe") # "exe"</paragraph>
+ </pycode>
+</section>
+
+<section id="GetFileLen">
+ <comment> GetFileLen ----------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id511600685050691">
+ <bookmark_value>FileSystem service;GetFileLen</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id301600685050869" localize="false">GetFileLen</h2>
+ <paragraph role="paragraph" id="par_id48160068505010">The builtin <literal>FileLen</literal> Basic function returns the number of bytes contained in a file as a <literal>Long</literal> value, i.e. up to 2GB.</paragraph>
+ <paragraph role="paragraph" id="par_id571613061005426">The <literal>GetFileLen</literal> method can handle files with much larger sizes by returning a <literal>Currency</literal> value.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id1001626179285915">
+ <input>svc.GetFileLen(filename: str): num</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id161600685050367"><emph>filename</emph>: A string representing an existing file.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id901600685050677">Dim fLen As Currency</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id721600685050519">FSO.FileNaming = "SYS"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id961600685050123">fLen = FSO.GetFileLen("C:\pagefile.sys")</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id201626271668440">fs.FileNaming = "SYS"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id361626271668899">fLen = fs.GetFileLen(r"C:\pagefile.sys")</paragraph>
+ </pycode>
+</section>
+
+<section id="GetFileModified">
+ <comment> GetFileModified -------------------------------------------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id901584811478304">
+ <bookmark_value>FileSystem service;GetFileModified</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id651584811478113" localize="false">GetFileModified</h2>
+ <paragraph role="paragraph" id="par_id191584811478936">Returns the last modified date of a given file.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id491626179415178">
+ <input>svc.GetFileModified(filename: str): datetime</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id25158481147822"><emph>filename</emph>: A string representing an existing file.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id911584811636241">Dim aDate As Date</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id351584811478870">FSO.FileNaming = "SYS"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id111584811478888">aDate = FSO.GetFileModified("C:\Documents\my_file.odt")</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id531626271811921">fs.FileNaming = "SYS"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id301626271812468">aDate = FSO.GetFileModified(r"C:\Documents\my_file.odt")</paragraph>
+ </pycode>
+</section>
+
+<section id="GetName">
+ <comment> GetName -------------------------------------------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id501584032366770">
+ <bookmark_value>FileSystem service;GetName</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id761584032366379" localize="false">GetName</h2>
+ <paragraph role="paragraph" id="par_id711584032366587">Returns the last component of a file or folder name in native operating system format.</paragraph>
+ <paragraph role="paragraph" id="par_id541613061300811">The method does not check if the specified file or folder exists.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id601626179529154">
+ <input>svc.GetName(filename: str): str</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id671584032366193"><emph>filename</emph>: A string representing the file name and its path.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id731626271995119">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id61158403236686">a = FSO.GetName("C:\Windows\Notepad.exe") ' Notepad.exe</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id91626272012883"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id221626272013299">a = fs.GetName(r"C:\Windows\Notepad.exe") # Notepad.exe</paragraph>
+ </pycode>
+</section>
+
+<section id="GetParentFolderName">
+ <comment> GetParentFolderName -------------------------------------------------------------------------------</comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id211584113432829">
+ <bookmark_value>FileSystem service;GetParentFolderName</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id94158411343258" localize="false">GetParentFolderName</h2>
+ <paragraph role="paragraph" id="par_id871584113432747">Returns a string containing the name of the parent folder of a specified file or folder name.</paragraph>
+ <paragraph role="paragraph" id="par_id611613061603039">The method does not check if the specified file or folder exists.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id791626179605250">
+ <input>svc.GetParentFolderName(filename: str): str</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id471584113432231"><emph>filename</emph>: A string with the file or folder name to be analyzed.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id100158411343225">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id161584113432533">a = FSO.GetParentFolderName("C:\Windows\Notepad.exe") ' C:\Windows\</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id871626272152981"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id711626272153205">a = fs.GetParentFolderName(r"C:\Windows\Notepad.exe") # C:\Windows\</paragraph>
+ </pycode>
+</section>
+
+<section id="GetTempName">
+ <comment> GetTempName ---------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id621583851172862">
+ <bookmark_value>FileSystem service;GetTempName</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id981583851172348" localize="false">GetTempName</h2>
+ <paragraph role="paragraph" id="par_id82158385117289">Returns a randomly generated temporary file name that is useful for performing operations that require a temporary file.</paragraph>
+ <paragraph role="paragraph" id="par_id391613061770924">The returned file name does not have any suffix. The folder part of the returned string is the system's temporary folder.</paragraph>
+ <paragraph role="paragraph" id="par_id971613061774934">The method does not create the temporary file.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id81626212807031">
+ <input>svc.GetTempName(): str</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id41583851448294">Dim fName As String</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id311583851172939">FSO.FileNaming = "SYS"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id381583851172545">fName = FSO.GetTempName() &amp; ".txt"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id381583851275546">' "/tmp/SF_574068.txt"</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id791626272322530">fs.FileNaming = "SYS"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id121626272322966">fName = FSO.GetTempName() + ".txt"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id991626272323308"># "/tmp/SF_574068.txt"</paragraph>
+ </pycode>
+</section>
+
+<section id="HashFile">
+ <comment> HashFile -------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id771601042514294">
+ <bookmark_value>FileSystem service;HashFile</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id251601042514585" localize="false">HashFile</h2>
+ <paragraph role="paragraph" id="par_id58160104251423">Hash functions are used by some cryptographic algorithms, in digital signatures, message authentication codes, fraud detection, fingerprints, checksums (message integrity check), hash tables, password storage and much more.</paragraph>
+ <paragraph role="paragraph" id="par_id301601042791356" xml-lang="en-US">The <literal>HashFile</literal> method returns the result of a hash function, applied on a given file and using a specified algorithm. The returned value is a string of lower-case hexadecimal digits.</paragraph>
+ <paragraph role="paragraph" id="par_id861601043268484" xml-lang="en-US">The hash algorithms supported are: <literal>MD5</literal>, <literal>SHA1</literal>, <literal>SHA224</literal>, <literal>SHA256</literal>, <literal>SHA384</literal> and <literal>SHA512</literal>.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id311626212875189">
+ <input>svc.HashFile(filename: str, algorithm: str): str</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id28160104251451"><emph>filename</emph>: A string representing an existing file.</paragraph>
+ <paragraph role="paragraph" id="par_id71601042959846" xml-lang="en-US"><emph>algorithm</emph>: One of the supported algorithms.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id1160104251483">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id391601042514664">sHash = FSO.HashFile("C:\pagefile.sys", "MD5")</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id161626272480577"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id221626272480829">sHash = FSO.HashFile(r"C:\pagefile.sys", "MD5")</paragraph>
+ </pycode>
+</section>
+
+<section id="MoveFile">
+ <comment> MoveFile -------------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id41584791330923">
+ <bookmark_value>FileSystem service;MoveFile</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id321584791330580" localize="false">MoveFile</h2>
+ <paragraph role="paragraph" id="par_id51584791330688">Moves one or more files from one location to another. Returns <literal>True</literal> if at least one file has been moved or <literal>False</literal> if an error occurred.</paragraph>
+ <paragraph role="paragraph" id="par_id631613062890648">An error will also occur if the <literal>source</literal> parameter uses wildcard characters and does not match any files.</paragraph>
+ <paragraph role="paragraph" id="par_id241613062902777">The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id851626214194605">
+ <input>svc.MoveFile(source: str, destination: str): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id721584791330406"><emph>source</emph>: It can be a <literal>FileName</literal> or <literal>NamePattern</literal> to designate one or more files to be moved.</paragraph>
+ <paragraph role="paragraph" id="par_id291584791330181" xml-lang="en-US"><emph>destination</emph>: If <literal>source</literal> is a <literal>FileName</literal> then this parameter indicates the new path and file name of the moved file.</paragraph>
+ <paragraph role="paragraph" id="par_id31613063334246">If the move operation involves multiple files, then <literal>destination</literal> must be a folder name. If it does not exist, it is created.</paragraph>
+ <paragraph role="paragraph" id="par_id391613063494599">If <literal>source</literal> and <literal>destination</literal> have the same parent folder, the method will rename the <literal>source</literal>.</paragraph>
+ <paragraph role="paragraph" id="par_id941613063476533">Wildcard characters are not allowed in <literal>destination</literal>.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <paragraph role="paragraph" id="par_id91626272612758">In the following examples only files are moved, subfolders are not.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id211584791330821">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id881584791330102">FSO.MoveFile("C:\Temp1\*.*", "C:\Temp2")</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id731626272648304"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id501626272649065">fs.MoveFile(r"C:\Temp1\*.*", r"C:\Temp2")</paragraph>
+ </pycode>
+</section>
+
+<section id="MoveFolder">
+ <comment> MoveFolder --------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id141584791330310">
+ <bookmark_value>FolderSystem service;MoveFolder</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id221584791330200" localize="false">MoveFolder</h2>
+ <paragraph role="paragraph" id="par_id301584791330868">Moves one or more folders from one location to another. Returns <literal>True</literal> if at least one folder has been moved or <literal>False</literal> if an error occurred.</paragraph>
+ <paragraph role="paragraph" id="par_id411613072570664">An error will also occur if the <literal>source</literal> parameter uses wildcard characters and does not match any folders.</paragraph>
+ <paragraph role="paragraph" id="par_id601613072595264">The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id181626214342806">
+ <input>svc.MoveFolder(source: str, destination: str): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id541584791330777"><emph>source</emph>: It can be a <literal>FolderName</literal> or <literal>NamePattern</literal> to designate one or more folders to be moved.</paragraph>
+ <paragraph role="paragraph" id="par_id551584791330279" xml-lang="en-US"><emph>destination</emph>: If the move operation involves a single folder, then <literal>destination</literal> is the name and path of the moved folder and it must not exist.</paragraph>
+ <paragraph role="paragraph" id="par_id11613072890641">If multiple folders are being moved, then <literal>destination</literal> designates where the folders in <literal>source</literal> will be moved into. If <literal>destination</literal> does not exist, it is created.</paragraph>
+ <paragraph role="paragraph" id="par_id301613072928159">Wildcard characters are not allowed in <literal>destination</literal>.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id1001584791330720">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id201584791330500">FSO.MoveFolder("C:\Temp1\*", "C:\Temp2")</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id11626275697779"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id361626275698068">fs.MoveFolder(r"C:\Temp1\*", r"C:\Temp2")</paragraph>
+ </pycode>
+</section>
+
+<section id="OpenTextFile">
+ <comment> OpenTextFile ----------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id531585320922937">
+ <bookmark_value>FolderSystem service;OpenTextFile</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id481585320922643" localize="false">OpenTextFile</h2>
+ <paragraph role="paragraph" id="par_id121585320922117">Opens a file and returns a <literal>TextStream</literal> object that can be used to read from, write to, or append to the file.</paragraph>
+ <paragraph role="paragraph" id="par_id591613073104711">Note that the method does not check if the given file is really a text file.</paragraph>
+ <paragraph role="paragraph" id="par_id951613073135036">The method returns a <literal>Null</literal> object (in Basic) or <literal>None</literal> (in Python) if an error occurred.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id21626214460569">
+ <input>svc.OpenTextFile(filename: str, iomode: int = 1, create: bool = False, encoding: str = 'UTF-8'): svc</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id551585320922678"><emph>filename</emph>: Identifies the file to open.</paragraph>
+ <paragraph role="paragraph" id="par_id671585320922388" xml-lang="en-US"><emph>iomode</emph>: Indicates the input/output mode. It can be one of three constants: <literal>svc.ForReading</literal> (default), <literal>svc.ForWriting</literal>, or <literal>svc.ForAppending</literal>.</paragraph>
+ <paragraph role="paragraph" id="par_id21585321398586" xml-lang="en-US"><emph>create</emph>: Boolean value that indicates whether a new file can be created if the specified <literal>filename</literal> doesn't exist:</paragraph>
+ <list type="unordered">
+ <listitem>
+ <paragraph id="par_id721613073434797" role="listitem">If <literal>True</literal> a new file and its parent folders will be created if they do not exist;</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id201613073469289" role="listitem">If <literal>False</literal> then new files are not created (default).</paragraph>
+ </listitem>
+ </list>
+ <paragraph role="paragraph" id="par_id771585321576210" xml-lang="en-US"><emph>encoding</emph>: The character set to be used. The default encoding is "UTF-8".</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id841585320922219">Dim myFile As Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id831585320922237">FSO.FileNaming = "SYS"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id141585320922524">Set myFile = FSO.OpenTextFile("C:\Temp\ThisFile.txt", FSO.ForReading)</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id341585321797611">If Not IsNull(myFile) Then</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id261585321805705"> ' ...</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id801613073013084">End If</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id971626275941924">fs.FileNaming = "SYS"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id271626275942194">myFile = fs.OpenTextFile(r"C:\Temp\ThisFile.txt", fs.ForReading)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id141626275942434">if myFile is not None:</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id721626275942719"> # ...</paragraph>
+ </pycode>
+</section>
+
+<section id="PickFile">
+ <comment> PickFile --------------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id1001583670342501">
+ <bookmark_value>FileSystem service;PickFile</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id421583670342501" localize="false">PickFile</h2>
+ <paragraph role="paragraph" id="par_id871583670342501">Opens a dialog box to open or save files.</paragraph>
+ <paragraph role="paragraph" id="par_id881613074436979">If the <literal>SAVE</literal> mode is set and the picked file exists, a warning message will be displayed.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id751626214688263">
+ <input>svc.PickFile(defaultfile: str ='', mode: str = 'OPEN', filter: str = ''): str</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id481583670342502"><emph>defaultfile</emph>: This argument is a string composed of a folder and file name:</paragraph>
+ <list type="unordered">
+ <listitem>
+ <paragraph id="par_id511613074665951" role="listitem">The folder part indicates the folder that will be shown when the dialog opens (default = the last selected folder).</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id631613074685308" role="listitem">The file part designates the default file to open or save.</paragraph>
+ </listitem>
+ </list>
+ <paragraph role="paragraph" id="par_id981583670342502"><emph>mode</emph>: A string value that can be either "OPEN" (for input files) or "SAVE" (for output files). The default value is "OPEN".</paragraph>
+ <paragraph role="paragraph" id="par_id31583670342502"><emph>filter</emph>: The extension of the files displayed when the dialog is opened (default = no filter).</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <paragraph role="paragraph" id="par_id881626276134300">The examples below open a file picker with the "txt" filter applied.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id791626276255605">' Basic</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id691583670342504">aFile = FSO.PickFile("C:\Documents", "OPEN", "txt")</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id681626276275531"># Python</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id701626276275757">aFile = fs.PickFile(r"C:\Documents", "OPEN", "txt")</paragraph>
+ </pycode>
+</section>
+
+<section id="PickFolder">
+ <comment> PickFolder ---------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id171583671701309">
+ <bookmark_value>FileSystem service;PickFolder</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id581583671701385" localize="false">PickFolder</h2>
+ <paragraph role="paragraph" id="par_id521583671701777">Opens a dialog box to select a folder.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id671626215115555">
+ <input>svc.PickFolder(defaultfolder: str = '', freetext: str = ''): str</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id951583671701872"><emph>defaultfolder</emph>: A string containing the folder name that will be displayed when the dialog is opened (default = the last selected folder).</paragraph>
+ <paragraph role="paragraph" id="par_id821583671701764"><emph>freetext</emph>: Text to display in the dialog (default = "").</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id391583764844033">' Basic</paragraph>
+ <paragraph role="bascode" id="bas_id921583671701610">aFolder = FSO.PickFolder("C:\Documents", "Choose a folder or press Cancel")</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id291626276402041"># Python</paragraph>
+ <paragraph role="pycode" id="pyc_id631626276402296">aFolder = fs.PickFolder(r"C:\Documents", "Choose a folder or press Cancel")</paragraph>
+ </pycode>
+</section>
+
+<section id="SubFolders">
+ <comment> SubFolders ---------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id901584016761417">
+ <bookmark_value>FileSystem service;Files</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id51584016761775" localize="false">SubFolders</h2>
+ <paragraph role="paragraph" id="par_id431584016761996">Returns a zero-based array of strings corresponding to the folders stored in a given <literal>foldername</literal>.</paragraph>
+ <paragraph role="paragraph" id="par_id431613075267241">The list may be filtered with wildcards.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id531626215218570">
+ <input>svc.SubFolders(foldername: str, filter: str = ''): str[0..*]</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id701584016761945"><emph>foldername</emph>: A string representing a folder. The folder must exist. <literal>foldername</literal> must not designate a file.</paragraph>
+ <paragraph role="paragraph" id="par_id471585648674921" xml-lang="en-US"><emph>filter</emph>: A string containing wildcards ("?" and "*") that will be applied to the resulting list of folders (default = "").</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id541584016761911">Dim folderList As Variant, folder As String</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id391584016761116">FSO.FileNaming = "SYS"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id701584016761482">folderList = FSO.SubFolders("/home/user/")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id631584016761643">For Each folder In folderList</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id871584016761279"> ' ...</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id881584016761778">Next folder</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id891626276476767">fs.FileNaming = "SYS"</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id131626276476995">folderList = fs.SubFolders("/home/user/")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id661626276477186">for folder in folderList:</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id891626276477415"> # ...</paragraph>
+ </pycode>
+</section>
+
+ <embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#SF_InternalUse"/>
+ <section id="relatedtopics">
+ <embed href="text/sbasic/shared/03/sf_textstream.xhp#TextStreamService"/>
+ <embed href="text/sbasic/shared/03160000.xhp#Input_h1"/>
+ <embed href="text/sbasic/shared/03020103.xhp#Open_h1"/>
+ </section>
+</body>
+</helpdocument>