Uncleaned reports needing regex

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
nas8e9
Posts: 2232
Joined: 21 Jun 2008 14:50

Re: Uncleaned reports needing regex

Post by nas8e9 »

highend wrote:Btw, here is a different approach.

Should be 5x times faster than the previous one... (on large folders)

Code: Select all

end exists("<curitem>") != 2, "No folder selected, aborted!";
	$list = folderreport("dump", "r", "<curitem>", "r", , "<crlf>");
	$list = regexreplace($list, "-{10,}|={10,}|^\d+\sfile\(s\).*?$", ""); // Remove comments (- and =) and footers
	$list = regexreplace($list, "^.*<DIR>", ""); // Remove unnecessary directories
	$list = regexreplace($list, "([A-Z]:\\.*$)", "</br></br><strong>$1</strong>"); // Tag existing directories
	$list = regexreplace($list, "\s{2,}\d{1,}.*?$", ""); // Cleanup files size, date, etc.


	$list = formatlist($list, "e", "<crlf>"); // Remove all empty lines
	$list = regexreplace($list, "\r\n", "</br>"); // Replace line endings with </br>

 	html($list, 800, 600);
Works great for me, thank you.

PeterB
Posts: 19
Joined: 09 Oct 2012 19:04

Re: Uncleaned reports needing regex

Post by PeterB »

This is beyond my grasping capabilities at this time. Permit some remarks nethertheless. Excuse me if my pov is non-programmer, non-regex-expert and thus not interesting for the highly-valued contributors of this thread (me not included), but there might be non-expert users of XYplorer, besides myself.


Regex info from the web is very hard to find, I didn't find suiting info there, sites as regular-expression.info are not helpful (und presumably laughable for anyone knowing that stuff), they try to sell books (and are not good advertizing for the books, in the way they present things).

For regex books, it's the same thing, especially since bookstores in good old europe did stop to present 5 or 8 or 10 books on the same difficult subject, in order for you to really select by depth AND by accessibility of the subject presented.

Example: My original regex question, if and how it's possible to have parts of an original text that is evaluated by the regex expression to find, AND (but at the same time, preserved (and not replaced by a literal string instead), in a two-fields environment like the replace dialog of my editors, first "replace...", then "with...", remains unanswered (which is not criticism for the the incredible posts we got here instead, but in a regex explaining environment (site, book), that's indeed a question to be answered since there are several such editors that allow for regex but don't explain and have such a two-fields-for-entering data plus a "contains regex" checkbox.

I also think that a "bunch-of regexes-in-a-row" (meaning splitting it up instead of doing highbrow code) as here is an extremely valuable kind of teaching, means of learning regex, so I'm thankful for this "code" (if you call such a thing code) here, and I'll will analyze as soon as I'll have got a good book about it.

Coming to my book remarks again: The unwillingness of displaying several such books instead of just the one or two the bookstore was given the highest percentage off by the publisher (!), could be be seen from the end (if not rather middle) of the nineties, very clearly, in the bookstores of Cologne, Bonn, Aachen, and in computer books even earlier than with let's say legal books where this is now also gone this way, for several years now. So, it's NOT Amazon the culprit here (NO "Radio killed the video store" or something), but profit maxizimization efforts by the (chain) owners having had overtaken in the nineties.

Another big problem: Mostly, you get bad (since badly paid and made-in-a-hurry) translations, instead of the English-language original, which could be "imported", three times its original price (and without having seen it beforehand). Hence the interest of university libraries, with their get-you-books-in-other-libraries service but which doesn't really work but for national sister libraries, and for specialized English-language / foreign books, you often don't get them anyway. One hint: Most books from O'Reilly are NOT accessible for non-programmers (and I've seen many from from them that appeared to me very badly written, under the reservation of course that given my non-background, I'm not really qualified to say so in the first place.

So, perhaps, regularly commanding 12 books with Amazon, then returning 9 to them, would be a valid approach that won't make you being thrown out of their customer base, but the problem of non-availability of many English originals would subsist. Could be overcome by doing the same with amazon.co.uk (I'm speaking for European customers, of course), but then, your returning costs won't be negligeable: Europe is one big entity for financial transfers, but not for postal services.


As for highend's superb coding, it's as the admin says, you're all the more so impressed by the elegant style, which mean compression of perhaps many lines of code into just a few ones, it's professional coding, you can see that even if you don't understand a bit about it as in my case (and even if it doesn't work yet, being a quick-made sketch: even the mastering required to do such a sketch is more than impressive). (As for triggering it when a file is selected, etc., can't say otherwise but what nas8e9 does said already.)

As for my criticism regarding admin, let me add another detail: If the introduction of better functionality is so "easy", meaning just some lines of code, it's all the less understandable why XYplorer is missing that functionality.


Finally, for Directory List & Print: For free, it's really great, but I discovered another quirk: It's missing a start button, which means, you have a directory selection tree, and if you select anything there in order to get somewhere else, you start the output, then, in order to stop it, you'll have to wait for the 2,000 item-dialog "do you really want to continue" (or something like that) - of course, this is more than amateurish (and not worth 20 dollars per pc! And indeed, the price is per pc, 9 pcs would be 180 bucks, from 10 pcs on you'd get some lesser price. Let's be happy that the admin here does not align his market strategy to such severe philosophy). So, do not touch this directory selection tree, but click on the "Path" button in that same tab "Directory", then enter the path manually. I happily accept this for free, but I wouldn't if I had to pay, and btw, if some lines of code do this, why paying 20 bucks per pc for such? Which is another example, then, of doing some lines of code, then building a gui around it, then sell it in numbers.

ADDED LATER: We've got another phenomenon with this software we see rather often: By their licence policy (or by too high a price in other cases but such licence problems are "too high a price" problems in the end and after all, too), the make it rather unappealing to buy their product, whilst in their free version, you get everything to make you happy as long as it's free (and not less than that, which would be "smarter" from their point of view), so we ve developers who try to discourage (!) you from bying, and here, they're doubly trying, from both sides! That's not that smart, even less so when they try from three sides as here, leaving out things that you would consider as being for granted, meaning, here, the lack of a start button, avoiding a folder tree running amok by just trying to navigate within it. That's being said, for free, it's great! (Imagine the green smiley here.)


P.S. I'm going to see which original regex books are available within the German university library net, then check them within amazon.com (!) - this is another valid hint regarding the library thing, btw. If you do it the other way round, you quicker get the best of the best for such IT-themed books, but you often will then learn that you would have to buy them from amazon usa, can't get them otherwise, which can be helluva frustrating.

highend
Posts: 14638
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Uncleaned reports needing regex

Post by highend »

Example: My original regex question, if and how it's possible to have parts of an original text that is evaluated by the regex expression to find, AND (but at the same time, preserved (and not replaced by a literal string instead), in a two-fields environment like the replace dialog of my editors, first "replace...", then "with...", remains unanswered
Please just paste an example of what you currently have (a full line), and the result that you like to see. Btw, the name of the editor you've used would be helpful as well. Regex comes in so many flavors, sometimes characters (like $ for the end of the line, etc) don't have the same meaning in a different flavor.

Superb coding? I have to read the help file every day (of XYplorer) because I'm too lazy to remember the options of these commands ;) It's just a little, novice-style try, to get things working...
One of my scripts helped you out? Please donate via Paypal

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

Re: Uncleaned reports needing regex

Post by admin »

Reading a help file is an art that only few people master...

Online
RalphM
Posts: 2051
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Uncleaned reports needing regex

Post by RalphM »

admin wrote:Reading a help file is an art that only few people master...
...because most of them can't be bothered :lol:
Ralph :)
(OS: W11 24H2 Home x64 - XY: Current x32 beta - Office 2024 32-bit - Display: 1920x1080 @ 125%)

highend
Posts: 14638
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Uncleaned reports needing regex

Post by highend »

Here, I've been trying for 2 hours to create a correct find/replace thing, "regex" checked of course, and then search for:

Dot, 3times a-z, 2 or more spaces, then anything, and all this at the end of the line,

which would make something like

\.[a-z]{3} *$

The dollar sign was not accepted, and the "*" did not make all those endless digits (size, date, time) selected; it seems a "*" has nothing to do with regex where it would be a dot instead, followed by a number, but even if I search for

\.[a-z]{3} [0-9 :.]{100}

the selection comprises only the dot, the suffix and any spaces and stops before the first number (size, date, time).

I have similar problems with the replace then, since a formula like

\.[a-z]{3}
E.g.:

Code: Select all

moonrise.avi                               1.360.556.032  19.09.2012 20:48:33
moo  nrise.mp3                                 360.556.032  19.09.2012 20:48:36

Code: Select all

(\.[a-z0-9]+)\s{2,}\d{1,}.*$
() = capture the extension in a backreference (you can replace this by $1 in most flavors)
\.[a-z0-9]+ = dot, any char between a-z and 0-9, multiple times (but at least one time (ofc you can replace the + sign with {3}))
\s{2,}\d{1,} = multiple spaces (at least two) followed by at least one to multiple digits
.*$ = everything up till the end of line

The replacement would just be:
$1

but it depends on what the editor is capable off (it seems the one you've tried can't use a regex in the replace term).
One of my scripts helped you out? Please donate via Paypal

PeterB
Posts: 19
Joined: 09 Oct 2012 19:04

Re: Uncleaned reports needing regex

Post by PeterB »

"but it depends on what the editor is capable off (it seems the one you've tried can't use a regex in the replace term)"...

and it has a bad help file on top of that...

Don, creating a good help file is an art (few programmers master), as for the task of reading a help file, that is simple with a good index... but I wasn't speaking of your help file here...

Read on, please, Don, since it concerns XYplorer, too.

First, let me say that yes, I'll be in need of some regex, but not the "replace" field "with this" field way, so I'm in need of a good regex book and must look out for one, and yes, up to now, I hadn't been aware that regex is THAT complicated and inscrutable for a beginner.

Then, I must add some details for Directory List & Print (DLP) (since I did sort a a review for it here which would become partly unjust if I didn't make the add-on). The automatic triggering of the building up of the "tree" of structure or "dump" (whatever you call it) can be avoided by unchecking the corresponding menu item in the "Set Up" menu item, sorry for that. There's another quirk, though, I seemed to have connected an extern hdd to my comp, after (?) loading DLP (you can't really "install" it, it seems), so I was only presented with the drive letter "h", but no substructure within the select tree - "reinstalling" = reloading DLP didn't make any difference, and I tried anything without success, so in the end I "accepted" the whole tree to be built up, but after 1 hour (!) and 60,000 files processed I gave up (I found no help, clicking on "Manual" didn't show any (for example, .pdf) manual). But after shutting down Windows, and starting it again (and reloading DLP again), the whole directory of drive h: appeared within the selection tree, and I could finally select the sub-directories I had wanted the dump for. (My notes on DLP before were done with "example" directories found on c: and d: .) So if anyone encounters a similar problem, connect the external things before running DLP, and it'll work.

So, I finally did one needed dump, with DLP, a structure as explained before, blank lines, then the folder names, then the file names (with suffix only); I formatted the folder names by hand (perhaps possible by DLP Pro, but trial not possible, only buy, and buy-per comp strategy is not an incentive for bying).

I also needed to make a dump of another style, without the files (can be set in DLP Free), but with the number of files within each folder - that's another frequent real-world dump scenario since for thousands of music files, for example, you would like to know if for a certain singer, group of subgenre, you'll have just some files, or dozens already (I admit that for professional use, you'd need the file names instead, but am speaking for people doing their "normal" stuff, and that's indeed a frequent need then).

So this (giving the numbers of files each folder contains) can be done with DLP Prof, but not with the free version. So I tried "Karen's Directory Printer" (KDP) (free, from the late and underrated Karen Kenworthy who did lots of such (always) free tools that are despised because their gnitting into commercial ones, and because their gui isn't pretty) - here, it's the other way round: When in DLP (Free), you cannot put output into a file but into the clipboard (which is quicker solution anyway if you want to process / store it in the application of your choice), with KDP, you can't dump into the clipboard but must dump it into a file (from which you get it to clipboard then).

Here, I was able to opt for the file numbers, but DKP didn't insert blank lines (and I didn't find a way for DKP to do so), so I had to manually check for the corresponding screen dump of DLP (just folders, with blank lines, but without file numbers), in order to see where to insert the blank lines manually, before the folder names. (I would have bought DLP instead, but not on a per-comp basis.) KDP puts the file numbers before the folder names, when I would like to have them after them, but I can live with that.

So, in the end, I got my music files numbers (!) that I had wanted, neatly printed out, in 3 columns on one page, and I know how to get them again next time, by KDP, then with only 5 minutes' manual work, and I regularly get my computer and other files' (!) lists, with DLP, neatly printed out on several pages in 2 columns (print-out in both cases by Word or whatever your text program is), in just a few moments (plus the manual bolding of the folders or just "upper" folders).

Of course, I also followed lots of net threads discussing output with the Windows commands, i.e. the current version of the ancient "Dos" commands, but I encountered too many problems there (problems with possible special characters like "!" within file names, and lots more), so that I didn't go into trying such things.

So, my posting here has two objectives: Telling people like me how to really GET such output they need or just want (in the past I often made such lists by hand (!), so sparing such cores to non-pogramming fellow users is a good thing), and of course, to explain a little how a GOOD "dump" function in XYplorer would be to have made, just have a look at some DLP options, including those that are greyed-out in the free version, and that would produce a dump function that would be useful - instead of the current one, producing a terrible list you'd expect from Dos.

@highend: "superb coding", I mean if some 5 lines do what you'd expect 30 lines to do, for me that's superb coding - of course, if it also works (I'm speaking of the core functionality in 5 or 8, instead of in 30 or 50 lines, I'm not speaking of exception handlers, on top of that, like message boxes when you try to run it on a file name instead of a folder name or things like that). On the other hand, I muse about another subject: How do you know what RAW data is to be processed by your code, or by any such code. I mean, I would not be able to write such a thing, even in 50 lines, since, among other things, I wouldn't know what's the raw data I then would have to transform (remember we're not speaking of transforming, by script or regex, a given XYplorer output, but we're speaking of presenting output from the Windows file system). Which is to say, if you don't have good knowledge of Windows internals, there is no sense in even trying to script something since you would have to make too many guesses as for the material you'd have to work on.

That's quite different from having any GIVEN output you then process, with scripting or regex or both, within a programmable editor or something. Just to stop other people like me, dreaming of doing it themselves when they see 5 lines of potentially superb code that "just does it". Just trying to be helpful, too, but on a level 3 or 4 levels beneath the level discussed here, no pun intended. XYplorer should be for just normal people, too.

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Uncleaned reports needing regex

Post by j_c_hallgren »

PeterB - Just a FYI: The longer the text of a post, the less likely Don and some others are to read it...Don has limited time to read posts here so the more condensed you can write it without making it unclear, the better it is for him...He's really good with English -but- it's not his native language so it may take just a bit longer to read.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

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

Re: Uncleaned reports needing regex

Post by admin »

j_c_hallgren wrote:PeterB - Just a FYI: The longer the text of a post, the less likely Don and some others are to read it...Don has limited time to read posts here so the more condensed you can write it without making it unclear, the better it is for him...He's really good with English -but- it's not his native language so it may take just a bit longer to read.
I would not read such a post even if it was in Colognian (Kölsch). Hey, I would not even listen to it if say Ellen Page would read it to me in a sauna. My only, spontaneous, and natural reaction to it is the thought: Go see a doctor.

Cheers from Cologne! :P

PeterB
Posts: 19
Joined: 09 Oct 2012 19:04

Re: Uncleaned reports needing regex

Post by PeterB »

I'm sorry for my latest sentence, I didn't want to express, XYplorer should be for NORMAL people, too, but wanted to say XYplorer should be for ORDINARY people, too, people who want a directory dump or something like that without doing programming / scripting for that.

I am a little bit astonished that the developer of such a program,

instead of saying, yes, indeed, you describe real-life scenarios here, so I could indeed implement some better such dump functionality in order to make such outputs possible, all the more so since it's not much coding work to do (see highend's scriptlet as an example),

prefers to say he doesn't even READ such a description, which means he thinks his program is good enough as it is, just producing the most standard Dos-like dumps (or even less so if you consider the numerous switches the original comments offer),

and prefers to declare you nuts.

That's a treatment users asking for missing core features AND explaining why these should be common (and not exotic in any way) don't get often from software houses.

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Uncleaned reports needing regex

Post by j_c_hallgren »

PeterB wrote:I'm sorry for my latest sentence, I didn't want to express, XYplorer should be for NORMAL people, too, but wanted to say XYplorer should be for ORDINARY people, too, people who want a directory dump or something like that without doing programming / scripting for that.
It's my feeling that most all "normal/ordinary" people are satisfied with Win Explorer and never even look for an alternate FM...so those who use XY are thus a bit more technical and can handle a more sophisticated program...however, that doesn't mean they need to be scripters either...I'm not, even with my 25+ yrs of a career doing COBOL, and rely on others to provide me with scripts as needed...we've had many cases where a beginning XY user is given a script to solve their unique or less common issue and that's a great way to handle it without Don's involvement.
I am a little bit astonished that the developer of such a program -------
and prefers to declare you nuts.

That's a treatment users asking for missing core features AND explaining why these should be common (and not exotic in any way) don't get often from software houses.
Well, you're new here and haven't yet maybe understood how Don works and the best way to interact and get results from him...A similar situation is where a brand new forum member posts a list of 10 "I want" items and hasn't yet found which are already in XY...that also gets a similar cold reception...

There have been cases where someone has posted a lengthy wordy description of a wish and gotten a bad response from Don but later someone else has posted same wish in a very short and concise form with a screenshot/listing of XY now and a mockup of what they want XY to do and a good simple explanation as to reasons why it'd be good for you AND OTHERS and Don has implemented it based on that.

So if you had posted it as such and it'd have taken 30 sec or less to read, your response could have been different...no guarantees but remember, Don is a SOLE developer, not a company so his time is very limited and if you post based on that understanding as I'd mentioned, you'd be better off, ok?

BTW, even I got lost somewhat in your lengthy post so I can empathize with Don.

The ole TV drama saying"Just the facts, ma'am!" applies here as well...compare the amount of text in your long posts with most other posts here (excluding script code, of course) and you may see why Don had that reaction...just my $.02 from being here for 6 yrs.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

Post Reply