i am a newer.
now i want to create a script to backup selected files.
i tried
copyitem , "*_backup_<date yyyymmdd>.?";
but seems it only backup the only first file which i selected
can anyone help me?
how to deal with selected files(help!)
-
admin
- Site Admin
- Posts: 64877
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: how to deal with selected files(help!)
Hi!
copyitem works on single items only (else I would have called it copyitems
).
So you want to make a copy of all selected items under a new name (defined by a pattern) in the same folder? I'm not among the top scripters here but I think this is currently not possible. If I'm right I will add it since it looks like a useful thing.
Don
copyitem works on single items only (else I would have called it copyitems
So you want to make a copy of all selected items under a new name (defined by a pattern) in the same folder? I'm not among the top scripters here but I think this is currently not possible. If I'm right I will add it since it looks like a useful thing.
Don
FAQ | XY News RSS | XY X
Re: how to deal with selected files(help!)
I think right now you have to collect an list of files with
$items = getinfo("SelectedItemsPathNames", "|");
This script could work:
or with 'report'
Thanks again for implementing {basename}
.
$items = getinfo("SelectedItemsPathNames", "|");
This script could work:
Code: Select all
$filelist = getinfo('SelectedItemsPathNames', '|'); //collect list of selected files
//get one time the current path
$file=gettoken($filelist, 1, "|");
$Path = regexreplace($file, "(.+)\\.+", "$1");
// for each file from list DO smtg:
$BatOutput = "";
$count = 1;
while(1)
{
$file=gettoken($filelist,$count,"|");
if("$file"==""){break;}
//split "path\file.ext" into "file" and "ext":
$Name = regexreplace($file, ".+\\(.+)\..*", "$1");
$Exte = regexreplace($file, ".+\.(.*)", "$1");
//compose new file name:
$Output = $Name . "_backup_<date yyyymmdd>" . '.' . $Exte;
// collect the output:
$BatOutput = $BatOutput . $Output<crlf>;
$count++;
}
// provide the output
text $BatOutput;
or with 'report'
Code: Select all
text report("{basename}_backup_<date yyyymmdd>.{ext}" . "<crlf>",1);.
-
admin
- Site Admin
- Posts: 64877
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: how to deal with selected files(help!)
I will add a new command CopyAs pattern, [itemlist]
FAQ | XY News RSS | XY X
Re: how to deal with selected files(help!)
You don't really need a loop to do this, another way that should do the work just fine :
Code: Select all
load report('copyitem "{Fullname}", "*_backup_<date yyyymmdd>.?"; ', 1),,s;Proud XYplorer Fanatic
Re: how to deal with selected files(help!)
ooh!it's really works fine.thanks!jacky wrote:You don't really need a loop to do this, another way that should do the work just fine :Code: Select all
load report('copyitem "{Fullname}", "*_backup_<date yyyymmdd>.?"; ', 1),,s;
-
admin
- Site Admin
- Posts: 64877
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: how to deal with selected files(help!)
Yeah, that was really a very clever idea of jacky!rongdorry wrote:ooh!it's really works fine.thanks!jacky wrote:You don't really need a loop to do this, another way that should do the work just fine :Code: Select all
load report('copyitem "{Fullname}", "*_backup_<date yyyymmdd>.?"; ', 1),,s;
Anyway, in the next beta version (8.80.0027) you will be able to do just this to achieve the same thing:
Code: Select all
::copyas "*_backup_<date yyyymmdd>.?";FAQ | XY News RSS | XY X
XYplorer Beta Club