-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathExport files with sequential prefix.EnScript
More file actions
49 lines (43 loc) · 1.96 KB
/
Export files with sequential prefix.EnScript
File metadata and controls
49 lines (43 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class MainClass {
void Main(CaseClass c) {
//Declare variables
EntryFileClass file();
LocalFileClass local(), log();
uint mastercounter;
ConnectionClass conn = LocalMachine;
DateClass date;
// Get current date & time
date.Now();
String datestring = date.GetString();
// Replace illegal filename characters that are in date & time string
datestring.Replace("/","-");
datestring.Replace(":","_");
//Create a unique export folder with the currect date & time as part of the folder name to avoid overwriting previous exports.
conn.CreateFolder(c.ExportFolder() + "\\Exported Files " + datestring);
// Create export log
if (log.Open(c.ExportFolder() + "\\Exported Files " + datestring + "\\log.csv", FileClass::WRITE)){
log.WriteLine("Full_Path,Export_Name,Extension,Created_Date,Last_Written,Last_Accessed,Logical_Size,Deleted");
//Recurse through all entries in case
forall (EntryClass entry in c.EntryRoot()){
// Check to see if current entry is selected
if (entry.IsSelected()){
file.Open(entry);
mastercounter++;
if (local.Open(c.ExportFolder() + "\\Exported Files " + datestring + "\\" + mastercounter + " - " + entry.Name(), FileClass::WRITE)){
local.WriteBuffer(file);
String isdeleted;
if (entry.IsDeleted())
isdeleted = "Yes";
else
isdeleted = "No";
log.WriteLine(entry.FullPath() + "," + mastercounter + " - " + entry.Name() + "," + entry.Extension() + "," + entry.Created().GetString() + "," + entry.Written().GetString() + "," + entry.Accessed().GetString() + "," + entry.LogicalSize() + "," + isdeleted + ",");
}
else
SystemClass::Message(16, "Error!", "Error opening export file");
}
}
}
else
SystemClass::Message(16, "Error!", "Error opening log file");
}
}