Page 1 of 1
Any way to supress "create folder" dialogue???
Posted: 07 Oct 2010 20:47
by Biggynuff
Hi all,
I posed a question some time ago about creating a script to move files and their parent folders from deep inside a 'nested tree' to any other selected folder
The original topic is here if it's of any interest to anyone:
http://www.xyplorer.com/xyfc/viewtopic.php?f=3&t=5040
Anyway, Jacky came up with a script that works incredibly well...
Code: Select all
$root = inputfolder(<curpath>);
$list = report("{Path}>{Name}<crlf>", 1);
$i = 1;
$files = '';
while (1)
{
$line = gettoken($list, $i, <crlf>);
if ('' == $line) { break; }
$path = gettoken($line, 1, '>');
$file = gettoken($line, 2, '>');
$folder = regexreplace($path, '^.+\\([^\\]+)$', '$1');
moveto "$root\$folder", "$path\$file";
$i++;
}
The relevant files are selected (I do a 'show all in branch' search), then a destination folder selected, and the files are moved as if by magic

The script works wonderfully but interupts itself to ask "folder does not exist . . . create now?" for each set of files moved. Is there any way to supress this? I sometimes have to click the mouse 200 times to say 'yes'
My guess is it's a 'system' thing and nothing can be done, just wondering
Thanks for any info
Biggy
Re: Any way to supress "create folder" dialogue???
Posted: 07 Oct 2010 21:32
by admin
Could you give me the exact text of the dialog (or a screenshot)?
Re: Any way to supress "create folder" dialogue???
Posted: 07 Oct 2010 22:57
by Biggynuff
Hi Don,
Here's a shot:
Capture2.JPG
I've created a simple test folder structure, completed a 'show all in branch' search (the most useful thing I've ever experienced, by the way

) selected all the files and then used Jacky's script to initiate moving all selected items to a chosen destination folder. For each folder created, if it doesn't exist (usually all of them or the script would be pointless

) the dialogue pops up
As above, I suspect it's a windows system thing. Not a great worry but it would be interesting if there's a workaround to prevent the box when the move needs to create 200+ folders
.
Re: Any way to supress "create folder" dialogue???
Posted: 08 Oct 2010 00:00
by SkyFrontier
First fool voting on this.
EDIT: Before any screaming... yes, I'm considering this as the other side of the coin, therefore NOT the same stuff ipsis literis.
Re: Any way to supress "create folder" dialogue???
Posted: 08 Oct 2010 02:12
by TheQwerty
Can't currently test it but this should prevent the prompts:
Code: Select all
$root = inputfolder(<curpath>);
$list = report("{Path}>{Name}<crlf>", 1);
$i = 1;
$files = '';
while (1)
{
$line = gettoken($list, $i, <crlf>);
if ('' == $line) { break; }
$path = gettoken($line, 1, '>');
$file = gettoken($line, 2, '>');
//Start of changes:
$folder = "$root\" . regexreplace($path, '^.+\\([^\\]+)$', '$1');
if (Exists("$folder") != 2) { //If the destination is not already an existing path.
$folder = New("$folder", 'dir'); //Create it.
}
moveto "$folder", "$path\$file";
//End of changes
$i++;
}
The additions, check to see if the destination of the moveto exists already, if it doesn't, then it uses New to create it.
There is a possible side-affect in that if the destination is created between the Exists and New calls, or if it exists as a file, New will use a suffix number to avoid collision, and this is where the files will be moved to. If you want to be alerted of these changes, or prevent them, then you could store the result of New in a different variable, and compare it to the original value of $folder, if they aren't equal XY did it's auto-avoid-collision suffixing.
Re: Any way to supress "create folder" dialogue???
Posted: 08 Oct 2010 07:53
by admin
I'll add an argument [skipprompttocreate] to moveto and copyto.
Re: Any way to supress "create folder" dialogue???
Posted: 08 Oct 2010 11:39
by Biggynuff
Thanks for the assistance guys, very much appreciated!
For obvious reasons, Don's suggestion of the added argument to the script command would simplify things completely, but I just wanted to thank both jacky and TheQwerty again... looking at the scripts provided gives a lot of information and examples to create my own. Superb

Re: Any way to supress "create folder" dialogue???
Posted: 08 Oct 2010 20:24
by SkyFrontier
Code: Select all
v9.60.0001 - 2010-10-08 15:42
+ SCs copyto and moveto enhanced: Now you can suppress any prompt to
create a not yet existing destination folder.
To achieve this economically the [filesonly] argument has been
converted to a binary field, now called [flags].
Syntax: copyto location, [source], [rootpath], [flags]
moveto location, [source], [rootpath], [flags]
flags (the desired values have to be binary-OR-ed)
0: [Default]
1: FilesOnly. For sources containing wildcards only files are
copied.
2: SkipPromptToCreate. Don't prompt, but create any non-
existing destination folder without asking.
Examples:
::copyto "c:\temp12"; //copy all; prompt
Thank you.
For the sake of backward
functionality, can the default behavior be to NOT prompt?
::copyto "c:\temp12"; //copy all; no prompt
Re: Any way to supress "create folder" dialogue???
Posted: 09 Oct 2010 09:42
by admin

The back functionality was to prompt, and the default is to prompt.