Report() and copy/moveto?

Discuss and share scripts and script files...
Post Reply
Winkie
Posts: 3
Joined: 29 Jul 2010 20:26
Location: The Netherlands

Report() and copy/moveto?

Post 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)
Winkie

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Report() and copy/moveto?

Post 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:

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Report() and copy/moveto?

Post by SkyFrontier »

[deleted]
Last edited by SkyFrontier on 29 Jul 2010 23:56, edited 1 time in total.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Report() and copy/moveto?

Post 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?)

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Report() and copy/moveto?

Post 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.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 65192
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Report() and copy/moveto?

Post 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!

Winkie
Posts: 3
Joined: 29 Jul 2010 20:26
Location: The Netherlands

Re: Report() and copy/moveto?

Post 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...
Winkie

Post Reply