SpaceObServer.Application.FileOperation

<< Zum Inhaltsverzeichnis >>

Navigation:  OLE Automation > Application > Methods >

SpaceObServer.Application.FileOperation

Description

Allows you to execute file operation like 'copy', 'move' or 'delete'.
 

Syntax

FileOperation (Operation : <String>, Destination : <String>, Flags : <String>, CollisionBehavior : <String>, DirLevel : <Integer>, [optional]LogFile : <String>, [optional]UndoScript : <String>)
 

Parameters

Operation

The operation that should be executed on a given scan, defined previously by setting a RootDirectory.

The following operations are supported:

"Delete"

Deletes all files.
Attention: Deletion cannot be undone without further notice. If you want to move the files to the recycle bin use the "recycle" operation instead.

"Recycle"

Moves all files to the recycle bin (if available, e.g. on Windows file system).

"Move"

Moves all items to the path which is specified via parameter "Destination".

"Copy"

Copies all items to the path which is specified via parameter "Destination".

"Zip"

Moves all items to a ZIP file  specified via parameter "Destination". ZIP files containing Unicode paths can only be unzipped properly by Unicode-compatible ZIP tools like WinRAR, WinZip, or 7-Zip.

"Execute"

An executable file,specified via parameter "Destination" will be called for every item and the full path of the item will be passed as parameter on the command line. The executable file may also be a powershell, batch or VBScript file (or something similar). The Windows Scripting FileSystemObject offers powerful and easy-to-use capabilities for file system and path operations.

Destination

The destination path for the operation defined via "Operation" parameter. In case of "Delete" or "Recycle" the parameter will be ignored.

Flags

Permissions of the original file will be used for the file in the new location.

Please note: Only available for "Move" and "Copy" operation.

"PreservePermissions"

Permissions of the original file will be used for the file in the new location.

Please note: Only available for "Move" and "Copy" operation.

"DeleteEmptyFolders"

Deletes all folders that have been emptied due to a move operation.

Please note: Only available for "Move" operation.

"CreateShortCuts"

Creates a shortcut at the original location pointing to the location the file has been moved to.

Please note: Only available for "Move" operation.

"CreateLinks"

Creates NTFS hardlinks for a moved file. If the creation of a hardlink is not possible, a symbolic link is used. If a symbolic link cannot be created, a Windows shortcut will be used as a fallback.

Please note: Only available for "Move" operation.

"KeepAfterZip"

Activate this option so that the original files are not deleted after copying to a zip file.

Note: This option is only available for the "Zip" operation.

"PreserveTimestamps"

Timestamps of the original file will be used for the file in the new location.

Please note: Only available for "Move" and "Copy" operation.

CollisionBehavior

Specify how name collisions are handled in case a move operation involves a file with the same name already existing at the destination.

Please note: Only available for "Move", "Copy" or "Zip" operation.

"KeepExisting"

An existing file will be kept and the new file will not be copied, moved or zipped.

"RenameExisting"

An existing file will be renamed (test.txt => test.txt.bak0) and the new file will be copied, moved or zipped.

"ReplaceExisting"

An existing file will be replaced by the new file.

"ReplaceOlderExisting"

The"modified" date of both files will be compared and only a file with a newer timestamp will replace an older file at the destination. Otherwise the file will be skipped.

DirLevel

Use this option to configure the level of parent directories to preserve. The first x parent directories will not be included in the destination path. Use -1 if you do not want to preserve the directory level.

For example, when moving a file "My Document.doc" of a scan "C:\temp" to destination "D:\Obsolete Files" you will get the following results:

x = -1 >  "D:\Obsolete Files\My Document.doc"
x = 0 > "D:\Obsolete Files\C\temp\My Document.doc"
x = 1 > "D:\Obsolete Files\temp\My Document.doc"
x = 2 > "D:\Obsolete Files\My Document.doc"

Please note: Only available for "Move", "Copy" or "Zip" operation.

LogFile

Produces a log file with a name of your choice under the path of your choice. Environment variables like %DATE% or %TIME% can be used in the file name.

UndoScript

Creates a batch file which can be run after the operation was finished to undo the changes applied during this operation.

Please note: Only available for "Move" and "Copy" operation on local Windows file systems.

 
Example

$SOS.FileOperation("Move", "C:\Backup", "[CreateShortCuts, PreserveTimestamps]", "ReplaceExisting", "0", "C:\logs\backup-log.txt") #PowerShell

SOS.FileOperation "Move", "C:\Backup", "[CreateShortCuts, PreserveTimestamps]", "ReplaceExisting", 0, "C:\logs\backup-log.txt" 'VBS

Moves all files of a (filtered) scan to a backup-folder "C:\backup" . The timestamps of the original files will be preserved and not changed due to this operation. A shortcut for each file will be left in the source folder.
The complete directory structure of the files will be kept,
existing files in the destination folder will be replaced and a logfile with name "backup-log.txt" will be created under "C:\logs".