Page 1 of 1

making a move all items to new folder script, need help

Posted: 02 Aug 2009 15:49
by wc96
Hi everyone, I'm quite new to scripting, trying to make a script that will put all the selected items (files/folders) into a new folder in the same panel.

Code: Select all

I started with the following:
"1. &Move into new Directory"
	$dir_name=input("Enter name of new directory to move files into ...","Directory Name");
	$dir_exists = exists("<curpath>\$dir_name");
	if ($dir_exists != 2) {
		new "<curpath>\$dir_name",dir;
	} elseif ($dir_exists == 2) {
		//do nothing
	}
        moveto "<curpath>\$dir_name"; // PROBLEM!! after new command above, all selection lost, newly created dir got selected.
how can I fix this? And is there any way to set the currently selected items into a variable so it won't get lost:
$current = <items>; // something like this, but I tried won't work. :?:

Re: making a move all items to new folder script, need help

Posted: 02 Aug 2009 16:13
by serendipity
I changed your script a bit:

Code: Select all

"1. &Move into new Directory"
   focus;
   $items = getinfo("SelectedItemsPathNames", "|");
   $dir_name=input("Enter name of new directory to move files into ...","Directory Name");
   $dir_exists = exists("<curpath>\$dir_name");
   if ($dir_exists != 2) {
      new "<curpath>\$dir_name",dir;
   } elseif ($dir_exists == 2) {
      //do nothing
   }
        moveto "<curpath>\$dir_name", $items;

Re: making a move all items to new folder script, need help

Posted: 02 Aug 2009 22:52
by wc96
this is excellent!! worked beautifully! I think the
$items = getinfo ("SelectedItemsPathNames","|");
was the missing link that can store the current selection into a variable.

:D :) :lol: