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

Discuss and share scripts and script files...
Post Reply
wc96
Posts: 32
Joined: 23 Apr 2008 22:34

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

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

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

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

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

wc96
Posts: 32
Joined: 23 Apr 2008 22:34

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

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

Post Reply