Backup files to User folders or same folder with extra extension appended
ActivePublic

Authored by Mud-H on Mar 31 2018, 10:26 PM.
Tags
  • Restricted Project
  • Restricted Project
Subscribers
None
Tokens
"Like" token, awarded by Mud-H.
1//This is mostly just a test for the Snippets and is not very clean...
2
3//==============================================================================
4// Handle the escape bind
5function doPathCopy(%srcFile,%tgtFile,%noOverwrite,%unique)
6{
7%tgtFile = getUniqueFilename(%tgtFile);
8createPath(%tgtFile);
9
10%result = pathCopy(%srcFile,%tgtFile,%noOverwrite);
11return %result;
12}
13//------------------------------------------------------------------------------
14//==============================================================================
15// Handle the escape bind
16function backupFileExt(%file,%extension)
17{
18%file = makeRelativePath(%file);
19%newFile = %file@"."@%extension;
20%success = doPathCopy(%file,%newFile,false,true);
21
22if (%success)
23return %newFile;
24
25return;
26}
27//------------------------------------------------------------------------------
28//==============================================================================
29// Handle the escape bind
30function backupFileHome(%this,%file,%unique,%homeSubDir)
31{
32%ext = fileExt(%file);
33%fileName = fileBase(%file);
34%relPath = makeRelativePath(%file);
35%filePath = filePath(%relPath);
36%newFile = %filePath@"/"@%fileName@"_"@localTime("timestamp")@%ext@".bak";
37%newFile = strreplace(%newFile,"//","/");
38
39//Store it into User Home APP/
40%newFile = getLocalFolder(%homeSubDir)@"/"@%newFile;
41%success = doPathCopy(%file,%newFile,false);
42
43if (%success)
44return %newFile;
45
46return;
47}
48//------------------------------------------------------------------------------
49//==============================================================================
50// Handle the escape bind
51function backupFileUser(%this,%file,%unique,%homeSubDir)
52{
53%file = makeRelativePath(%file);
54%newFile = getLocalFolder(%homeSubDir)@"/"@%file;
55%success = doPathCopy(%file,%newFile,false,%unique);
56
57if (%success)
58return %newFile;
59
60return;
61}
62//------------------------------------------------------------------------------
Mud-H created this paste.Mar 31 2018, 10:26 PM
Mud-H changed the title of this paste from FileCleaner - Remove X empty lines and automatic script headers to Backup files to User folders or same folder with extra extension appended.Mar 31 2018, 10:28 PM
Mud-H edited the content of this paste. (Show Details)

No TorqueScript support :( How they could have miss it 📟 😝

Interesting version history which allow to see what changed 😈 And what is that nom nom nom buttons..

In P1#11, @Mud-H wrote:

Interesting version history which allow to see what changed 😈 And what is that nom nom nom buttons..

Agreed!

Mud-H changed the visibility from "All Users" to "Public (No Login Required)".Apr 1 2018, 8:02 PM