Quicksearch files only

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Quicksearch files only

Post by Ghosty »

Return all matching files in subfolders?

This includes folders named with ".txt" ....

Code: Select all

$findext="*.txt;*.pdf";
$found=quicksearch($findext, <curpath>);
  msg "Found...<br>" . $found,0;

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

Re: Quicksearch files only

Post by admin »

Use switch /f to find only files:

$findext="*.txt;*.pdf /f";

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Quicksearch files only

Post by highend »

Code: Select all

$findext="*.txt;*.pdf";
$found=quicksearch($findext . " /f", <curpath>);
One of my scripts helped you out? Please donate via Paypal

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Quicksearch files only

Post by Ghosty »

ok so just add /f once, Thanks!

BTW /f is not in the chm.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Quicksearch files only

Post by highend »

Ofc it is

Main Topics - Quick Search - Search Pattern Switches
One of my scripts helped you out? Please donate via Paypal

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Quicksearch files only

Post by Ghosty »

From my CHM dated Wednesday, ‎April ‎7, ‎2021, ‏‎3:00:00 PM
20210624 chm no f-2.jpg
20210624 chm no f-2.jpg (32.97 KiB) Viewed 655 times
20210624 chm no f-1.jpg
20210624 chm no f-1.jpg (33.3 KiB) Viewed 655 times

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Quicksearch files only

Post by highend »

Read my last post again...
One of my scripts helped you out? Please donate via Paypal

Ghosty
Posts: 47
Joined: 31 May 2010 01:41

Re: Quicksearch files only

Post by Ghosty »

You did! Thanks!

This is the script, seems to work. It moves any txt/pdf from subfolders into the current folder.

Code: Select all

"Move Here from Subfolders - txt/pdf"
	$moveext="*.txt;*.pdf;";
	$movefiles = quicksearch($moveext . " /f", <curpath>);
	// msg "Found:<br>" . $movefiles, 0;
	foreach($movefile, $movefiles, <crlf>, "e") {
		status "Moving " . gpc($movefile, "file") . " ...", , "progress";
		$movebase=gpc($movefile,"path");
		// same $gpc($movefile,"component", -2, 1);
		if ($movebase != "<curpath>") {
			// $m="moveto(<br>curpath=<curpath>";
			// $m="$m <br>movefile=$movefile";
			// msg $m,0;
			moveto(<curpath>,$movefile);
		}
		
	}
I put this in a file %appdata%\XYplorer\Scripts\MoveHere_FromSub_txtpdf.xys and added a user-button to the toolbar,
On left click:

Code: Select all

load "MoveHere_FromSub_txtpdf.xys"
On right click:

Code: Select all

run  '"C:\Program Files\Notepad3\Notepad3.exe"  "%appdata%\XYplorer\Scripts\MoveHere_FromSub_txtpdf.xys"'  ;

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Quicksearch files only

Post by highend »

You could probably save a lot of time by moving all those items in one go...

Code: Select all

    $moveExts  = "*.txt;*.pdf";
    $moveFiles = quicksearch($moveExts . " /f");
    // Remove all items that are already in this path
    $escaped   = regexreplace(<curpath>, "([\\.+(){\[^$])", "\$1");
    $moveFiles = regexreplace($moveFiles, "$escaped\\[^\\]+?(\r?\n|$)");
    if ($moveFiles) { moveto , $moveFiles, , 1, 2, 2; }
And by the way, XY has inbuilt variables, so:

Code: Select all

run  """C:\Program Files\Notepad3\Notepad3.exe"" ""<xyscripts>\MoveHere_FromSub_txtpdf.xys""";
would work as well and is agnostic about where you store the script files...
One of my scripts helped you out? Please donate via Paypal

Post Reply