Page 1 of 1

Report() and copy/moveto?

Posted: 29 Jul 2010 21:44
by Winkie
Hi

This week I started experimenting with XYplorer Scripting after using XYplorer for about 20 days, enjoying every minute.

Today I'm having difficulties with the following short script:

Code: Select all

	End ("<curitem>"==""),  "No file(s) selected!"
	load report('moveto "E:\Some path\" . 
	substr("{Basename}", 0, 1), :list; ', 1),,s;
It's supposed to move files like this:

Code: Select all

E01.jpg -> Some path\E\
F01.jpg -> Some path\F\
G01.jpg -> Some path\G\
H01.jpg -> Some path\H
I01.jpg -> Some path\I
Let's assume I select all above files.
The problem is that the script moves all files to the first folder (E) at first move. Resulting in four error messages "Cannot move, cannot read source" because everything is already moved.

When running the script in step mode I can see all paths correctly. But result are a bit more weird as above. Let's assume here that I select E01,jpg, F01.jpg and G01.jpg. Now at first move again the selected files are moved to folder E AND afterwards H01.jpg is moved to folder F and I01.jpg is moved to folder G.

So am I thinking wrong to use moveto inside report() and is there a way to overcome this problem?

Greetings,
Winkie

P.S. @admin: I started this post before realizing Step Mode was doing weird. If this post belongs in Bug Reports, please move. (As far as I know latest Beta 9.30.0023 has the same issues)

Re: Report() and copy/moveto?

Posted: 29 Jul 2010 23:20
by Stefan
Hi Winkie and welcome.

Huh, this Load Report() stuff locks always funny, and sometime i will learn how to do this too.

Do you need to do it that way? Then please wait till an Load-Report expert comes to aid.


Till that *I* would it do the old way:

Code: Select all

"Move files to Initial SubFolder"

  //Get list with fullnames of selected files:
  $FILES = report("{FullName}<crlf>", 1);

  $NewPathMain = "E:\Some path";

  $LOOP = 1;
  while(1)
  {
    //For Each File in Files Do:
    $file = gettoken($FILES, $LOOP, "<crlf>");
    if ($file==""){break;}
    
     //For the initial SubFolder we need the file name:
     $NamePart = regexreplace($file, ".+\\(.+)", "$1");

     //For the initial SubFolder we need first sign of the file name:
     $SubFolder = substr($NamePart, 0, 1);

     //If first sign is an lower-case char make it upper-case:
     if(asc($SubFolder)>=97 && <= 122){$SubFolder = chr(asc($SubFolder)-32);}

     //Build up the full path to the initial SubFolder:
     $NewPath = $NewPathMain\$SubFolder;

     //If the initial SubFolder does not exist create it:
     if (exists($NewPath)!=2){new $NewPath, dir;}

     //Attention! Ready! Action:
     moveto $NewPath, $file;
   
  incr $LOOP; //NEXT iteration
  }

HTH? :lol:

Re: Report() and copy/moveto?

Posted: 29 Jul 2010 23:35
by SkyFrontier
[deleted]

Re: Report() and copy/moveto?

Posted: 29 Jul 2010 23:46
by Stefan
SkyFrontier wrote:...could this be adapted to parent folders, also, Stefan? I mean - checking for a given sublevel and moving contents one level above?
Thanks!
:evil: do not hijack threads and mix-up things Sky!

Mod, delete this two posts please. (can i become an mod?)

Re: Report() and copy/moveto?

Posted: 30 Jul 2010 00:00
by SkyFrontier
I thought I was doing a good service by linking related issues, Stefan, so similar problems could lead to simple solutions thus cleaning the forum and making stuff coherent.
But... as you wish. Post deleted and will delete this after a response out of you.
I'm sorry. I was just trying to help.

Re: Report() and copy/moveto?

Posted: 30 Jul 2010 07:29
by admin
This appears to work:

Code: Select all

End (getinfo("CountSelected")==0),  "No file(s) selected!";
   load report('moveto "E:\Test\" .
   substr("{Basename}", 0, 1), "{Fullname}"; ', 1),,s;
Nice script!

Re: Report() and copy/moveto?

Posted: 30 Jul 2010 19:43
by Winkie
Stefan wrote:Huh, this Load Report() stuff locks always funny, and sometime i will learn how to do this too.

Do you need to do it that way? Then please wait till an Load-Report expert comes to aid.
I'm still learning how script in XY, so I didn't know. But thanks for showing me the 'old way', that's always handy for the future.
admin wrote:This appears to work:

Code: Select all

End (getinfo("CountSelected")==0),  "No file(s) selected!";
   load report('moveto "E:\Test\" .
   substr("{Basename}", 0, 1), "{Fullname}"; ', 1),,s;
Nice script!
Confirmed, that works! Many thanks!
Seems logical not to use :list in report() now I think about it...