Beispielskripte (Plugins)
Plugin "Dateihandling" (i2dxFiles)
Feb 192015Das image2data-Plugin "Dateihandling" (i2dxFiles) stellt alle Funktionen bereit, um Manipulationen des lokalen Dateisystems aus dem Skript heraus vornehmen zu können. Dateien und Verzeichnisse können angelegt, gelöscht, kopiert oder verschoben werden, Logdateien geschrieben- oder Dateien (auch rekursiv) gefunden werden. Eine kleine Auswahl der zur Verfügung stehenden Befehle zeigt das folgende, leicht verständliche, Skript.
// ************************************************************** // * sample_i2dxfiles.i2dspt * // * * // * Sample script for the i2dxFiles (file handling) plugin * // * REQUIRES THE INSTALLED PLUGIN TO COMPILE AND RUN! * // * * // * Press F9 to execute the code or F7/F8 to debug it * // * * // * Contact www.norpa.eu if the plugin is required but missing * // ************************************************************** {$I i2dxFiles} var i: Integer; sFileName: String; oFiles: TStringList; begin // Get the free space on drive c: in mbytes i2dDebugOut(Format('There are %d mega bytes left on drive c:', [(i2dxFilesDriveFree('c') / 1024 / 1024)])); // List all files on c:\ and their size oFiles := TStringList.Create; try i2dxFilesFindFiles('c:\', '*', False, False, oFiles); for i := 0 to oFiles.Count - 1 do i2dDebugOut(Format('The file "%s" contains %d bytes', [oFiles[i], i2dxFilesFileSize(oFiles[i])])); finally oFiles.Free; end; // Check if a file exists sFileName := i2dInputBox('Filename', 'Filename to check existence for:', ''); if sFileName = '' then i2dCancelProcess('No filename entered'); if i2dxFilesFileExists(sFileName) then i2dDebugOut('"' + sFileName + '": file exists') else i2dDebugOut('"' + sFileName + '": file doesn''t exist'); // Get the suffix of the file i2dDebugOut(Format('The suffix of the entered filename "%s" is "%s"', [sFileName, i2dxFilesExtractFileExt(sFileName)])); end.