another quiz: filter challenge

A collection of especially useful xplorer² topics and ideas. New users may find it helpful to look here before searching the other forums for information. >>>>>> Please post new material in the relevant forum. (New stuff posted here will be removed.) Thanks. -fg-

Moderators: fgagnon, nikos

User avatar
fgagnon
Site Admin
Site Admin
Posts: 3737
Joined: 2003 Sep 08, 19:56
Location: Springfield

another quiz: filter challenge

Post by fgagnon »

This thread was originally posted  in the xplorer² Professional forum.        
Moved here 19-May-2010 =fg=
=====================================================


a filter/selection challenge.

In xplorer², find and select:
all files in a folder having extension .abc and/or .def  
for which there is no .xyz file with the same base name.

Background: the need arises after culling digital camera files.
Having already removed the .jpg versions of many photos, I now want to efficiently find and remove the related .CR2 and .XMP files.

I have yet to find a solution I like.
Last edited by fgagnon on 2010 May 19, 19:30, edited 1 time in total.
Mr.Pleasant
Silver Member
Silver Member
Posts: 281
Joined: 2006 Dec 29, 12:56
Location: Utrecht, NL

Post by Mr.Pleasant »

Hi Fred,
What about this one. Select all files in the folder. Go to the Script wizard (ctrl+b), and enter

Code: Select all

md "$B",move "$F" "$B\"
This will make folders named after the plain name of the files, and then puts the file into this folder.
Now "select columns" (Alt+k), and add "Contents [S]" to the set of columns. Folders with a .xyz file in it will have a 3 in this column, the others a 2. Sort on this column, and remove the folder with a 2.
Now select all folders, flatten them, and move all files to the original folder. Remove all previously created folders. (the 'create folders' part actually was inspired by BRX answer to the other challenge a few days ago :wink: )
Mr.Pleasant
Silver Member
Silver Member
Posts: 281
Joined: 2006 Dec 29, 12:56
Location: Utrecht, NL

Post by Mr.Pleasant »

Or, much easier, just select all *.xyz files (by sroting or filtering on extension) and move them all to a empty folder that you have opened in the opposite pane.
Now select all *.xyz in that particular folder, and go to the script wizard, and enter:

Code: Select all

move "$I\$B.*" "$P\"
press execute (DOS), and all files with the same base name as the *.xyz will be moved from the old folder into the folder with the *xyz files. Remove the remaining *.abc and *.def files.
bst
New Member
Posts: 7
Joined: 2008 May 15, 21:38
Location: Germany

Post by bst »

Hi,

+ *.abc,*.def
$ FOR %i IN ($S) DO @if not exist %~ni.xyz echo %~fi

Finally select and copy all names from console2 and put them into a scrap container via insert clipboard.

It would be nice here to have an external x2-tool putscrap.exe which reads filenames from stdin and put them in a new scrap, so that:

$ FOR %i IN ($S) DO @if not exist %~ni.xyz echo %~fi | putscrap

would work.

cu, Bernd
User avatar
snakebyte
Gold Member
Gold Member
Posts: 430
Joined: 2003 May 07, 07:14
Location: Seattle
Contact:

Post by snakebyte »

Mr.Pleasant wrote:Or, much easier, just select all *.xyz files (by sroting or filtering on extension) and move them all to a empty folder that you have opened in the opposite pane.
Now select all *.xyz in that particular folder, and go to the script wizard, and enter:

Code: Select all

move "$I\$B.*" "$P"
press execute (DOS), and all files with the same base name as the *.xyz will be moved from the old folder into the folder with the *xyz files. Remove the remaining *.abc and *.def files.
Nice trick! example such as these show the true potential of command script wizard which I have only used in few instances. I will definitely give it a shot next time when I face similar complex file org situation.
Help! I'm an AI running around in someone's universe simulator.
User avatar
nikos
Site Admin
Site Admin
Posts: 15794
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

a sort of selection algebra is required here!
narayan
Platinum Member
Platinum Member
Posts: 1430
Joined: 2002 Jun 04, 07:01

Post by narayan »

How about using the build-checker? No scripts required at all!
(Ref: P. 185 of User Manual)

Load the same folder in opposite panes and then press CTRL+F12.
Enter the appropriate extensions in the "From" and "To" fields, and press Enter.
User avatar
nikos
Site Admin
Site Admin
Posts: 15794
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

narayan, you become the second doctor in xplorer2 philosophy :)
BRX
Silver Member
Silver Member
Posts: 304
Joined: 2002 Feb 08, 12:12

Post by BRX »

I like these challenges. :-)

It's good to show of the possibilities of x2, especially of such things like the batch assistant, comparing etc. which probably very few use to their potentials.

I like the solutions so far. Here's another one just for the sake of competition:

Flatten the folder with the files to scrap. Select/Filter files with .abc, hardlink (Ctrl-C/Ctrl H) into a newly created folder, repeat with .def.

Mass rename the hardlinked files with $B.xyz. Send them with Ctrl-S to scrap (two-paned, the other one), Compare with Ctrl-F9, revert selection with NUM *, delete selected.

Sounds more complicated as it is. I prefer hardlinking because speed of copying and hardlinks don't need additional space on harddisk.
User avatar
fgagnon
Site Admin
Site Admin
Posts: 3737
Joined: 2003 Sep 08, 19:56
Location: Springfield

Post by fgagnon »

Last night I tried and liked Mr.Pleasant's 2nd submission (the Or, much easier approach) and I was going to try bst's script this morning, when I saw narayan's solution!  :wow:  
Not being a programmer, using the Build checker had not entered my (alleged) mind. ;)  

This is such an elegant solution. :spin:  :party: :party: :party:
Thank you, "doctor" narayan!  
and especially thank you, nikos, for incorporating a build checker in xplorer² in the first place. :D

PS - Note that I use only the [Not built] option in the Check build wizard because some of the file dates (the .jpgs in my case) are not necessarily in date order with the other file types.
Mr.Pleasant
Silver Member
Silver Member
Posts: 281
Joined: 2006 Dec 29, 12:56
Location: Utrecht, NL

Post by Mr.Pleasant »

This is such an elegant solution.
True! This one of those features I wouldn't think of easily. This kind of challenges on the forum is really great, and makes you see how others make use of X2. Very educational!
We want more challenges!  :D
User avatar
fgagnon
Site Admin
Site Admin
Posts: 3737
Joined: 2003 Sep 08, 19:56
Location: Springfield

Post by fgagnon »

@ We want more challenges! -

Users are welcome to post their own 'challenges' any time.  
Indeed, responding to "How do I ...?" questions is a good part of what this forum has always been about.  Neither of the two recent "quiz:" threads had solutions that the originators were happy with.  It's not that we are trying to initiate a feature on the board -- goodness knows, we are not that organized. :shrug:

If users like the quiz/challenge idea, I suggest the following guidelines (in an attempt to be uncharacteristically organized).

> Start each challenge in a new topic. (One to a thread.)  
> Challenges should be based on a real-world need for which you have either found a clever solution using xplorer², or for which you are not satisfied with the way you currently work it.
> If you have a clever solution, don't post it until after users come up with their own -- you might find something better by not 'leading' readers down your path.  :sneaky:
> Be creative, have fun, learn.  :D
stereobit
Member
Member
Posts: 56
Joined: 2005 Jan 14, 10:58
Location: Germany

Post by stereobit »

@BRX: Your solution is exactly what i needed - unfortunately nearly two years ago. I never asked here for a solution, cause I never thought that's possible with x². It's truly an amazing piece of software.
BRX
Silver Member
Silver Member
Posts: 304
Joined: 2002 Feb 08, 12:12

Post by BRX »

stereobit wrote:@BRX: Your solution is exactly what i needed - unfortunately nearly two years ago. I never asked here for a solution, cause I never thought that's possible with x². It's truly an amazing piece of software.

Agreed. Nice to hear you think my solution is useful. In fact I've used this method or similar ones to solve quite a lot file managing problems I previously considered unsolvable or requiring tedious hour-long manual work.

You aren't by any chance also frequenting the German CCB? ;-)

Anyway, the trick to create hardlinks, to work from there with editing, sorting, deleting, comparing and whatever has helped me countless times. I'm nagging Nikos to expand on x2's hardlinking capabilities - to no avail so far, but I won't give up. :-)
RTC
Member
Member
Posts: 41
Joined: 2007 Jan 24, 23:06
Location: Paramaribo-Suriname

Help with "how do I..."

Post by RTC »

fgagnon wrote:@ We want more challenges! -

Users are welcome to post their own 'challenges' any time.  
Indeed, responding to "How do I ...?" questions is a good part of what this forum has always been about... :D
Members,

I’m looking for some help with a sort of task which I’m sure must be doable with xp2…
Anyone could point me into the direction?

the scenario:

-- lot of different type of files
-- need to know which sort of extensions I have
-- so not all the files but just one of the extensions
-- in a txt file

Your suggestions would be highly appreciated…

thanx

                       *** RTC ***

disclaimer
author has just little more as average xp2 knowledge…no heavy programming or whatsoever…just KISS   :oops:
Post Reply