Any way to supress "create folder" dialogue???

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Biggynuff
Posts: 110
Joined: 13 May 2010 14:08

Any way to supress "create folder" dialogue???

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

My guess is it's a 'system' thing and nothing can be done, just wondering

Thanks for any info

Biggy

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

Re: Any way to supress "create folder" dialogue???

Post by admin »

Could you give me the exact text of the dialog (or a screenshot)?

Biggynuff
Posts: 110
Joined: 13 May 2010 14:08

Re: Any way to supress "create folder" dialogue???

Post 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 8) ) 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 :lol: ) 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


.
To see the attached files, you need to log into the forum.

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

Re: Any way to supress "create folder" dialogue???

Post by SkyFrontier »

First fool voting on this. :roll:

EDIT: Before any screaming... yes, I'm considering this as the other side of the coin, therefore NOT the same stuff ipsis literis.
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...

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Any way to supress "create folder" dialogue???

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

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

Re: Any way to supress "create folder" dialogue???

Post by admin »

I'll add an argument [skipprompttocreate] to moveto and copyto.

Biggynuff
Posts: 110
Joined: 13 May 2010 14:08

Re: Any way to supress "create folder" dialogue???

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

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

Re: Any way to supress "create folder" dialogue???

Post 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
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: 66351
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Any way to supress "create folder" dialogue???

Post by admin »

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

Post Reply