8.5.22 SplitFile (split a file)
- Purpose
-
Partitions a file by a specified size.
In JP1/Script 07-50 or later, the command supports large files.
- Syntax
SplitFile (FilePath, SplitSize, [DirPath], [Option] [, SplitCnt])
- Arguments
-
- FilePath
-
Write the full path of the file as a character string or as a variable that stores this value.
- SplitSize
-
Specify the split size as a number (bytes) or as a variable that stores this value.
Even with a large file, the maximum split size is 2,147,483,647 bytes.
- DirPath
-
Specify a folder in which to store the split files, using a character string or a variable that stores this value.
This value is optional. If you omit this value, the folder containing the file set in FilePath is assumed.
- Option
-
Specify the following optional value:
Value
Meaning
Delete
Delete the file specified in FilePath after it is split.
- SplitCnt
-
Specify a variable for storing the number of split files. Omit this argument if not required.
- Description
-
The SplitFile command partitions a files by the specified size and stores the split files in the specified folder. The command returns True on successful execution, or False if an error occurs.
The file names of the split files have the file name specified in FilePath, plus the extension .xxx (where xxx is a number from 001 to 999, then restarting at 1000).
- Notes
-
-
Take care when specifying a file or folder in the folder set in the environment variable ProgramFiles (normally the Program Files folder on the system drive) or WinDir (normally the Windows folder on the system drive). For details, see 1.8.2 Command behavior.
-
You can configure access permissions for split files. In the following registry key, set the access permissions beforehand.
- Registry key
-
HKEY_LOCAL_MACHINE\SOFTWARE\Hitachi\JP1/Script\SPTX\Option
- Value name
-
SecurityAttributesSucceed
- Value datatype
-
REG_DWORD
- Value
-
0: Access permissions are not set.
1: Access permissions are set to "Inherit access permissions from parent folders".
2: Access permissions are set to "Everyone: Full control".
If no value is set, or a value other than those above is set, the setting defaults to 0.
- When the setting takes effect
-
The setting takes effect the next time the script file is executed.
-
- Example
' Partition the file "C:\FDCOPY.TXT" to fit on 1.44-MB ' floppy disks and store the split files on floppy disks. ' (Ref) 1.44MB FD = 1423KB = 1423 * 1024B ' 1.25MB FD = 1221KB = 1221 * 1024B ' 720KB FD = 713KB = 713 * 1024B ' 640KB FD = 640KB = 640 * 1024B Dim file1, size1, splCnt, filePath file1 = "FDCOPY.TXT" size1 = 1423 * 1024 SplitFile ("C:\"+file1, size1, _TEMP_, , splCnt) Dim cnt1 ' Create floppy disks for the number of split files. For cnt1 = 1 To splCnt filePath = _TEMP_+file1 Select Case Len (cnt1) Case 1 filePath = filePath+".00"+cnt1 Case 2 filePath = filePath+".0"+cnt1 Case Else filePath = filePath+"."+cnt1 End Select ' Copy the temporary files to floppy disks. Copy (filePath, "A:\", Overwrite) If splCnt - cnt1 <= 0 Then MessageBox ("Copying to floppy disk has ended.", OK) Exit For End MessageBox ("Insert floppy disk number" + cnt1+1", _ OKCancel) If _MSG_RTN_ = Cancel Then Exit For End Next
- JP1/Script version
-
Supported from JP1/Script 05-10.