<< Click to Display Table of Contents >> Navigation: 3. Script Language > Filesystem-Commands > ! Smart Package Robot 's Filesystem-Commands |
Smart Package Robot 's File Commands
Smart Package Robot can work with files in any way you want.
You can:
• Write or append to Log-Files (ATF.)
• Write text- or binary files (CTF.)
• read text- or binary files (CFF.)
• change the actual directory and drive (CHD.)
• copy files (COP.)
• rename files (REN.)
• delete files (DEL.)
• Make directories (MKD.)
• delete directories (RMD.)
• check if a file exists (IEF.) or
• Wait until a file appears or disappears (WFF.)
• Find any Text or Wildcard Pattern in files using the sophisticates FIF. - command
• Split the path of a file into its parts
• Split the Filename into its parts (GFT.)
• Get file-date and version
• work with INI-Files (CTI./CFI.)
• Split large files of any size to smaller files and (FIL.SPLIT FILE)
• Concatenate these files to the original file again (FIL.JOIN FILE)
• copy files using the Windows-Shell (SHF.)
• move files using the Windows-Shell (SHF.)
• copy, rename and move directories and / or files using the SHF.-command
• and much more ...
You can also apply these methods to groups of files, using FEF.
Some commands call internally the windows shell, these commands are limited to the normal path length of ~260 characters.
Most other commands directly call the NTFS-API (Advanced Programming Interface) and therefore support one or more of these features:
The NTFS-Direct Feature enables you to use the full power of the NTFS-Filesystem.
You can use Pathes up to 32760 Bytes!
Note that most window-programs may not be able to access files deeper then ~250 Bytes-Path-length.
If you see this Logo, then you can use "Wildcards" in the Filesystem-Commands.
These are the well-known "*" and "?" - Wildcards.
Using Wildcards in the Pathname is not recommended, use them only in the Filename or extension.
Note that the first file or folder that fits to the wildcard is been taken.
Use Wildcards with extreme caution, as this may lead to unexpected results if there are multiple fitting files.
If you want to debug your Script safely, you can use the
OPT.SAFEFILE|1
this will bring up such a Messagebox for destructive File-Operations like DEL., RMD. REN. and DCP.
You can choose between
- "Yes" - this will start the requested file-operation
- "No" - this will prevent the requested file-operation and set the Timeout-Flag
- "Cancel" - this will prevent the requested file-operation and set the Timeout-Flag and end the script.
If you try to delete Pathes >260 characters with the Windows Explorer or Shell,
you may run into an error like the one below.
These Pathes can only be deleted, using the SPR-Command "RMD.".
Error-Message "Path longer then 260 character".
Please note that the Explorer and Anti-Virus Tools may lock files and folders and prevent
the RMD.-Command from working as expected. In this case the Command will not delete the folder completely and the Timeout-Flag will be set.
You can use the supplied NTFSD-Explorer for simple File-Operations with very long pathes.
Note that Files may not have the proper Icons if you go deeper then 260 Characters.
This is not as bug its because the windows shell does not support this currently.
Here is a more complex Sample that will do a lot of file operations.
'
'SPR Script-file: FIF-Replacer
'Purpose: Find a Date in a Text-File and
'replace it with another Date
'Author: Theo Gottwald
'Creation date: 10-07-2014 at 14:28:09
'===========================================================
'#EXE:?path\
'#SPI:ForceWrite
$$FIL=?path\Test.txt
$$TAR=?path\Target.txt
' Delete it if it existed before
DEL.$$TAR
' We search for the line with the date
$$SRC=11.?7.*
' New date - we replace the old one with this
$$NEW=12.08.2015
FIF.tww|$$FIL|$$SRC
' Check if we found something
JIZ.$$000|Lab_nf
' Note that once we take something from TOS, it is automatically removed
$$LIN=$$000
$$STA=$$000
$$END=$$000
$$STR=$$000
$$TRE=$$000
PRT.String: $$STR Found in Line: $$LIN
PRT.From Character $$STA to $$END
GLC.$$FIL|$$REA
' Line where String is minus 1
CAL.$$TOL=$$LIN-1
' Copy all lines until the wanted Line
FOR.$$COP|1|$$TOL
LFF.$$FIL|$$COP|$$RES
' We use the delimiter that was found in the source file
$$TXT=$$RES$$TRE
ATF.$$TAR|$$TXT
NEX.
' Here is the Line with the date
LFF.$$FIL|$$LIN|$$TXA
RPL.$$TXA|$$STR|$$NEW
$$TXB=$$TXA$$TRE
ATF.$$TAR|$$TXB
' Now copy Rest of file
' Line where String is plus 1
CAL.$$TOL=$$LIN+1
FOR.$$COP|$$TOL|$$REA
LFF.$$FIL|$$COP|$$RES
' We use the delimiter that was found in the source file
$$TXT=$$RES$$TRE
ATF.$$TAR|$$TXT
NEX.
:Lab_nf
MBX.!
ENR.
'===========================================================
' BACKUP.Skript
' This Script will Backup 4 Folder including ALL Subfolders
' From Drive F: to Drive G:
' Compiled as EXE, it will run AS SYSTEM ('#EXV:) and therefore
' survive an User-Logoff.
' It will also not be killed with the "KillRobots" or CleanUp-Button because of the SYSTEM Rights.
' All Folders will be Backuped "in Parallel", the Script will wait until all Backus are ended.
'
'#EXE:?path\
'#SPI:ForceWrite
'#MAN:ra
'#EXV:Robi
$$DAT=$date$
VAO.$$TIB=
$$NAM=Folder1
GSB.Lab_Copy
$$NAM=Folder2
GSB.Lab_Copy
$$NAM=Folder3
GSB.Lab_Copy
$$NAM=Folder4
GSB.Lab_Copy
WRS.!$$TIB
MBX.Ready
ENR.
'===========================================================
:Lab_Copy
PRR.
$$SRC=F:\$$NAM\
$$TAR=g:\$$DAT\
PRT.Dircopy:$$SRC->$$TAR
MKD.$$TAR
DCP.$$SRC|$$TAR
PAU.15
END.
PRE.$$TIC
$$TIB=$$TIB,$$TIC
RET.