hi
dear Script yodas
please help me with this probably simple one
select this folder"___mywebsite"
backup it in same location.
and rename the backup "mywebsite_01"
merci beaucoup
Calude
script query for simple backup
-
calude
- Posts: 355
- Joined: 13 Aug 2008 10:16
- Location: Switzerland
- Contact:
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: script query for simple backup
[first of all, sorry for the delay]
Here's a script (very particular to this job). It will backup a selected folder whose name matches ___* pattern and copy it as *_01 in the selected folder's parent location. No overwriting, no auto-suffixing.
Here's a script (very particular to this job). It will backup a selected folder whose name matches ___* pattern and copy it as *_01 in the selected folder's parent location. No overwriting, no auto-suffixing.
Code: Select all
if (exists(<curitem>)==2) && (regexmatches(<curbase>, "^___.*") != "") {
if !exists(getpathcomponent(<curitem>,path).'\'.substr(<curbase>,3)."_01"){
copyas substr(<curbase>,3)."_01", gettoken(<curitem>,path), <curitem>;
} else {echo "destination already exists<crlf 2>".getpathcomponent(<curitem>,path).'\'.substr(<curbase>,3)."_01"}
}Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
calude
- Posts: 355
- Joined: 13 Aug 2008 10:16
- Location: Switzerland
- Contact:
Re: script query for simple backup
thanks a lot Sammay
works as intended, except the original folder name was (my mistake) "__GN2" (2 underscores) therefore I got "N2_01"
can you explain what to correct.
again merci beaucoup
Calude
works as intended, except the original folder name was (my mistake) "__GN2" (2 underscores) therefore I got "N2_01"
can you explain what to correct.
again merci beaucoup
Calude
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: script query for simple backup
Remove one underscore from the regex pattern in the first line: "^___.*" to "^__.*"
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
calude
- Posts: 355
- Joined: 13 Aug 2008 10:16
- Location: Switzerland
- Contact:
Re: script query for simple backup
Hi againSammaySarkar wrote:Remove one underscore from the regex pattern in the first line: "^___.*" to "^__.*"
I did remove one underscore in the first line
but with "__GN2"
I got "N2_01"
the "G" was truncated
have a nice week-end
Calude
-
highend
- Posts: 14942
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: script query for simple backup
Code: Select all
if (exists("<curitem>") == 2) && (regexmatches("<curbase>", "^_+")) {
$newName = regexreplace("<curbase>", "^_+") . "_01";
if !(exists("<curpath>\$newName")) {
copyas $newName, , "<curitem>";
} else { echo "Destination already exists:<crlf 2>" . "<curpath>\$newName"; }
}One of my scripts helped you out? Please donate via Paypal
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: script query for simple backup
sorry for my careless effort.
btw, my original script needed one more change in the form of substr(<curbase>,3) -> substr(<curbase>,2)
btw, my original script needed one more change in the form of substr(<curbase>,3) -> substr(<curbase>,2)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
calude
- Posts: 355
- Joined: 13 Aug 2008 10:16
- Location: Switzerland
- Contact:
Re: script query for simple backup
Sammay, Highend
both script work
until
I start it a second time and all I get is a warning saying "Destination already exists"
instead of incrementing backup GN2_01 to GN2_02 etc...
I dont need any warning its a backup/versions procedure
Calude
both script work
until
I start it a second time and all I get is a warning saying "Destination already exists"
instead of incrementing backup GN2_01 to GN2_02 etc...
I dont need any warning its a backup/versions procedure
Calude
-
highend
- Posts: 14942
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: script query for simple backup
Code: Select all
if (exists("<curitem>") == 2) && (regexmatches("<curbase>", "^_+")) {
$newBaseName = regexreplace("<curbase>", "^_+");
$lastEntry = gettoken(listfolder(, "$newBaseName*", 2+4), -1, "|");
if ($lastEntry) { $newName = $newBaseName . "_" . format(regexmatches($lastEntry, "\d+$") + 1, "00"); }
else { $newName = $newBaseName . "_01"; }
copyas $newName, , "<curitem>";
}One of my scripts helped you out? Please donate via Paypal
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: script query for simple backup
And here's mine!
Code: Select all
setting backgroundfileops, 0;
if (exists(<curitem>)==2) && (regexmatches(<curbase>, "^__.*") != "") {
$incr = '01';
while (exists(getpathcomponent(<curitem>,path).'\'.substr(<curbase>,2).'_'.$incr) != 0) {
$incr = $incr + 1; $incr = (strlen($incr)!=2)?('0'.$incr):($incr);
}
copyas substr(<curbase>,2).'_'.$incr, gettoken(<curitem>,path), <curitem>;
wait 50; status "backed up"; wait 50;
}Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
calude
- Posts: 355
- Joined: 13 Aug 2008 10:16
- Location: Switzerland
- Contact:
Re: script query for simple backup
Thanks guys
both scripts work beautifully
Calude
both scripts work beautifully
Calude
XYplorer Beta Club