Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I don't know how you'd do that in a query (or if it is even possible. What I would do is go through the table and build a dictionary using val(b1) & "," & val(b2) as the key and the frequency as the value. Then I would scan the dictionary and pick the keys with the highest frequencies. Implementation depends on the language you are using.

Sometimes, even if you can do it in a query, the query can be so convoluted that it is cleaner to do it in code.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Please start a new thread for your question.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Glad to help.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

when i dubleclick the sortfiles.vbs exactly nothing happens

That's because you didn't read the instructions. I told you to run it by

cscript sortfiles.vbs

Apparently I was unclear in that you do this from the command line. vbScript files are executed by either cscript.exe (console) or wscript.exe (window). The default is wscript.exe and when run with the default, each echo pops up a msgbox. If you run it the way that I suggested you force it to run under cscript.exe and each echo writes a line to the console window. You can force cscript.exe to be the default by running (from a console window as Administrator)

cscript //h:cscript //nologo //s

Following that you can run the script from the command line by simply typing

sortfiles

It will take longer to run with all the echo statements but it's worthwhile in case something goes wrong - you can see exactly where it stops.

Okay i got it, but it sems like i have titles with just a-b.jpeg is it possible to process like that also ?

It certainly is but you didn't include that in the original spec. You could change the code to

set fso = CreateObject("Scripting.FileSystemObject")

for each file in fso.GetFolder(".").Files

    ext = lcase(fso.GetExtensionName(file.Name))

    if ext = "jpg" or ext = "jpeg" Then
        flds = Split(file.Name,"-")
        if Ubound(flds) >= 2 Then
            folder = flds(0) & "-" & flds(1) & "\"
            if not fso.FolderExists(folder) Then
                Wscript.Echo "Creating folder",folder
                fso.CreateFolder(folder)
            end if
            Wscript.Echo "Moving:",file.Name
            Wscript.Echo "    To:",folder …
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The script looks at all jpg files in the folder. If the file name has at least three fields separated by "-" then it creates a folder name from the first two fields and moves the file. In other words, it will process

a-b-c.jpg
a-b-c-d.jpg
a-b-c-d-e.jpg
etc

but not

a-b.jpg

If you replace

fso.MoveFile file.Name, folder

with

'fso.MoveFile file.Name, folder

(commented out) then you can run the script to see what files would be moved without actually moving them. When you say "nothing happens" what exactly do you mean? What is echoed back in the command window? Did you save the script file in the same folder as your jpg files? I tested the script by creating the files

Stefan-Rafa-400x500-123uirjht5-1.jpg
Stefan-Rafa-300x300-12a32s-1.jpg
Stefan-Rafa-100-123uirjht5-1.jpg
John-Doe-400x500-123uirjht5-1.jpg
John-Doe-3-1423555-400x200.jpg
John-Doe-300x300-123uirjht5-1.jpg

and running the script. It worked as I understand you wanted it to.

D:\test>dir /s
 Volume in drive D is D-Data
 Volume Serial Number is 366A-6FA3

 Directory of D:\test

2017-08-21  08:14    <DIR>          .
2017-08-21  08:14    <DIR>          ..
2017-08-21  08:14                 0 John-Doe-300x300-123uirjht5-1.jpg
2017-08-21  08:14                 0 John-Doe-3-1423555-400x200.jpg
2017-08-21  08:14                 0 John-Doe-400x500-123uirjht5-1.jpg
2017-08-21  08:14               613 sortfiles.vbs
2017-08-21  08:14                 0 Stefan-Rafa-100-123uirjht5-1.jpg
2017-08-21  08:14                 0 Stefan-Rafa-300x300-12a32s-1.jpg
2017-08-21  08:14                 0 Stefan-Rafa-400x500-123uirjht5-1.jpg
               7 File(s)            613 bytes

     Total Files Listed:
               7 File(s)            613 bytes
               2 Dir(s)  916,313,260,032 bytes free

D:\test>cscript sortfiles.vbs
Creating folder John-Doe\
Moving: John-Doe-3-1423555-400x200.jpg
    To: John-Doe\
Moving: John-Doe-300x300-123uirjht5-1.jpg
    To: John-Doe\
Moving: John-Doe-400x500-123uirjht5-1.jpg
    To: John-Doe\
Creating folder Stefan-Rafa\
Moving: Stefan-Rafa-100-123uirjht5-1.jpg
    To: Stefan-Rafa\
Moving: Stefan-Rafa-300x300-12a32s-1.jpg
    To: Stefan-Rafa\
Moving: Stefan-Rafa-400x500-123uirjht5-1.jpg
    To: Stefan-Rafa\

D:\test>dir /s
 Volume in drive D is D-Data
 Volume Serial Number …
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I don't normaly just provide code but

  1. It's pretty simple
  2. I'm really bored

Copy the following code into a file named SortFiles.vbs in the same folder containing your images. If you run it by

cscript sortfiles.vbs

the script will create the required folders under the current folder and move the files into each folder as requested. I suggest that you make a copy of the images in another folder for safe-keeping before you run the script. You can always delete the copy after you see if the results are what you wanted.

set fso = CreateObject("Scripting.FileSystemObject")

for each file in fso.GetFolder(".").Files
    if lcase(fso.GetExtensionName(file.Name)) = "jpg" Then
        flds = Split(file.Name,"-")
        if Ubound(flds) >= 2 Then
            folder = flds(0) & "-" & flds(1) & "\"
            if not fso.FolderExists(folder) Then
                Wscript.Echo "Creating folder",folder
                fso.CreateFolder(folder)
            end if
            Wscript.Echo "Moving:",file.Name
            Wscript.Echo "    To:",folder
            fso.MoveFile file.Name, folder
        end if
    end if
next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If it's not replacing then it's not the right code.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Can't see what he did to deserve it this time.

Consider it like a lifetime achievement Oscar for his accumulated body of work.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you have "world beating" ideas, you don't actually have to reveal them to be successful, at least in the short term. You just have to find enough idiots who believe you. Example "I have a secret plan to defeat ISIS"."

Then again, that same person said in his book, "You can't con people, at least not for long. You can create excitement; you can do wonderful promotion and get all kinds of press, and you can throw in a little hyperbole. But if you don't deliver the goods people will eventually catch on."

Eventually people just learn to ignore you.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Well, first I would learn how to program in C++. What I would not do is ask someone else to do it without showing that I had put some effort into doing it myself first.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Hold the phone Chuck. What if we feed the tuna fish mayonnaise before we kill them and put them in the can?

  • Bill Blaze - Night Shift [1982]
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Are you looking for something like teracopy?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

As I understand it, his response to the troll label is "it's a silly sounding word so it doesn't apply to me." A Trump-worthy counter-argument if I ever heard one.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Have you tried listening to something like Delta Waves?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

nobody should store their backups in compressed form

I use Macrium Reflect for my imaging and I alwys use compressed. However, I also use verify. Before that I used Acronis for years (corporate as well as personal). In all they years I have never had a backup image refuse to restore because of a corruption. In any case, I do a full image (automatically) on the first of every month and a differential every other day. Even if one were to get corrupted I would only lose out on one day.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I have had the odd project get corrupted like this and the only solution I could find (if you can call it a solution) is to rebuild the project from scratch. Fortunately you should still have all the code (.vb) files to copy/paste into the new project. You might even be able to recreate the form easily by copy/paste into the designer file. Make sure to keep a copy of the old project files as a backup.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You'll increase the odds of getting an answer if you start a new thread rather than hijacking an old and already solved thread.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
If TextBox4.Text == TextBox10.Text Then
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Why not just compare the string values?

rproffitt commented: Sounds equivalent to the intent. +12
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Do you really think that if people can't even be bothered to post in the Programming section that they'd bother to post in a specific language forum?

rproffitt commented: My observation is many think the Community Forum is for all questions. "Ask the community?" Yes. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

they treat every word of online communication with the same amount of deliberate thought and intent as you treat your primary form of communication.

When I'm shooting the sh!t with my friends, then, yes, you are probably correct. But shooting the sh!t is not my primary mode. The problem is when these same people communicate as if all conversations should be had on that level. When someone is seeking my assistance I expect a higher level of conversation than "Dude. Code broak. Plz hlp."

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I think a cool smartwatch app would be to have it pair with your self-driving car. If the smartwatch app detects that you are having a heart attack it drives you to the nearest hospital while calling 911.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Anything but a Dell.

rproffitt commented: I have similar feelings about HP. +12
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

My favourite data fail is from many years ago when hard drives were low capacity and expensive. Hard drive space was at such a premium that companies like DoubleSpace made mega-bucks selling compression software. This particular user had a 20 meg hard drive. Yes, that's what I said. 20 meg. And, yes, I'm that old. The drive, once DoubleSpace was installed, showed as having roughly 40 meg of capacity. He happily loaded his data onto the drive. After some days of use he had a thought. Looking at the drive he noticed that his 40 meg drive had a rather large file that was taking up almost 20 meg of his precious space (the file was named something like dblspace.bin). He decided that since he hadn't put the file there he could simply delete it, thereby freeing up another 20 meg of space for his own files. I think we all know how that turned out.

rproffitt commented: I had to refresh my memory. I think it was dblspace.000. +0
cereal commented: I still have an Olivetti PCS 286 with one of those "doublespaced" disks, hah :D +15
rubberman commented: I had a 286 running QNX back in the 1980's. I was director of engineering for a software company in Syracuse NY doing real-time software. +14
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Furthermore, in most fast food places, the menu is prominently displayed so you can browse it while waiting in line. How many time have you seen someone get to the front of the line and then look up at the menu saying "let's see....". If you are in a face-to-face conversation I can see asking a not quite thought-out question. But when you have the time to compose your thoughts and ask a question online, there is no reason not to put some thought into composing a coherent question.

rproffitt commented: But I'm in a hurry. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Now look at it from the point of view of the people in line behind that "moron". If they have to repeatedly waste their time waiting for these obliviots to be served won't they be more likely to take their business to another establishment?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I think that in a few years the term "self-driving car" will refer to a car that you drive yourself rather than a car that drives itself.

ddanbe commented: This is one to put in "memorable quotations"! +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Why bother. Just install f.lux. It's free and easy to use. I know the latest Windows 10 update has their own version but, based on my experience with Microsoft making simple things complicated, I am sticking with f.lux.

rproffitt commented: The old do I buy or make a wheel problem? +12
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Are students becoming really that dumb these days?

Lazy and entitled? Yes. Dumb? Possibly.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

DaniMeals tell their customers to start following more rules, such as wearing specific badges, comply with ordering in specific ways... etc, etc...

I would imagine that if you started violating some of the more obvious daniweb rules (like "keep it pleasant") on SO you would be infracted/booted very quickly.

As for the food analogy, imagine someone is in line at McD's. The attendant says to that person "what would you like?" and the person says "I want food". How likely is it that a satisfactory exchange will happen quickly?

Now compare that to the person who comes to Daniweb and not only posts a programming question in the Community Forum, but only bothers to enter "My program won't work. What's wrong with it" without providing any context or code?

If the idea is to be more attractive to google by providing a quick answer then it becomes necessary to ask a coherent question that does not require several back-and-forth exchanges before the actual question is stated.

So I think you might agree that some rules/guidelines are necessary.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

A word of advice - you seem to like starting threads with the title

(ask)

That is not the best way to get an answer. A thread with a meaningful title is far more likely to get a timely, and useful response.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I never saw the benefit of downloading videos.

I will occasionally download a video to show to my mother (for example) at her place where there is no internet access, or to watch later at the cottage where, unlike at home, I have a very restrictive data cap.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm not sure full-blown (over-blown??) IDEs are the best environments for those starting to programme.

I agree. Sitting someone down at the controls of a 747 is not the best introduction to learning to fly a plane.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Here we had the start of a pleasant thread and you had to turn it into a Windows-bashing conversation. I guess there is a little bit of troll in the best of us ;-P

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Just for the record, I agree with everything HG said.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you are on the computer in the evening you might want to installing f.lux. I've been using it for months. It automatically adjusts the level of blue light coming from your screen after sunset. I know that Windows 10 bow has its own version of this but I suspect (like most MS extras) that f.lux is much simpler to use. It's free, BTW.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Yeah. I have those nights when my mind just won't turn off. The trick (for me) is to concentrate on something totally unrelated. I listen to a piece of music in my head, concentrating on every note. By doing that I force my mind out of the rut it is in. Works most times. For me the piece is (believe it or not) Classical Gas by Mason Williams. You would think I would pick a slow piece but I also visualize the finger picking so two senses are being focused.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I agree with pty. Python is a great first choice. That's why many schools/universities are using it as a first language. You chould learn C but I would wait until you have a grounding in programming fundamentals. There are gotchas in every language, but the ones in c are harder to get your mind around until you understand the basics.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Got DeleteFile (kernel32) to work. Streams.exe is no longer required. Updated project is attached.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

What you are asking is like a mechanic posting the question "how do I build a car". Your question is to big to be addressed on this site. If you've read the Daniweb Posting Rules then you'd know that we expect you to show some effort first.

rproffitt commented: Or a surgeon asking "Where does this go?" +12
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

VBscript does not have an IIF (a stupid omission IMO) so I had to roll my own. The project is in vb.net but cads.vbs is vbscript.

If you are wondering about the extra wide lines int he header of cads.vbs (trailing blanks and a closing tic), for vb.net and vbscript I set the syntax highlighting for comments to grey bg and black fg so that comments are visibly distinct from code. I got into that habit years ago so that commented-out code would be obvious (more important in languages that support /* and */ block comments). Having the blanks and closing tic makes it look a lot less raggedy.

Yes, I'm kinda anal.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I've never been a fan of readme files. They are fine for project files where you will likely need note of building an application, or for distribution packages where you might need extra information on installing a package. But sometimes you want to add a comment to a file (perhaps you want to make a note of where the file came from). Some picture formats (jpg, for example) support an internal comment. And sure, Windows supports comments (sorta). But you have to

Right mouse click -> properties -> details -> comment

and even then you only get to see the first few characters. Also, there is no similar support for folder comments.

That's why I decided to write CommentShell. With a couple of minor registry changes (additions) you can now add a comment of any size to a file or folder. This is done using a feature of NTFS called Alternate Data Streams. You may not be familiar with ADS but you have probably seen their influence. When you download a program and try to run it you will have seen the warning that pops up. The warning is displayed because of the presence of an ADS named Zone.Identifier. The contents of this ADS on a downloaded jpg on my computer is

D:\Downloads>cat  1085.jpg:Zone.Identifier
[ZoneTransfer]
ZoneId=3
HostUrl=http://media.twnmm.com/storage/29705514/1085

Note that the ADS is fully named by prefixing it with a colon and adding it to the file name. You can create an ADS with just about any name you want and …

ddanbe commented: Nice tip! +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try FastStone. It's free and has the feature you want (and quite a few more).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The only problem I've had with Outlook is that it is so difficult to find the options. Menus and sub-menus, each with buttons, buttons, buttons, advanced options, etc. I use Outlook on my wife's laptop and Thunderbird (which I prefer) on mine. One of these days I'll convert Outlook to Thunderbird and be done with it.

gentlemedia commented: Thumbs up for Thunderbird! +0
rproffitt commented: Go for Thunderbird. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The scripting encoder object can also be used to encode/decode html although I don't know the correct parameters. You could probably find them with a little googling.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Microsoft used to supply a utility program, screnc for encoding scripts. All it did was use the builtin scripting encoding object. The encoding object can be scripted directly as

set fso = CreateObject("Scripting.FileSystemObject")
set enc = CreateObject("Scripting.Encoder")

For each file in Wscript.Arguments

    if fso.FileExists(file) then

        srce = fso.OpenTextFile(file).ReadAll
        dest = enc.EncodeScriptFile(".vbs",srce,0,"VBScript")

        out  = fso.GetBaseName(file) & ".vbe"

        fso.OpenTextFile(out,2,True).Write(dest)

    end if

Next

You use it like

encode myscript.vbs

and it creates myscript.vbe. Because encoded scripts have to be in a form that can be understood by the script engine, the vendor utility would likely just have used the encoding object. Scripts, once encoded, can be decoded but the process is messy. I dug around in my archives and found the following. I don't know where it came from originally but I did a test encode using the above script and it decoded perfectly. Copy the following code into decode.vbs and try running it against your encoded scripts.

Option Explicit

Const BIF_NEWDIALOGSTYLE = &H40
Const BIF_NONEWFOLDERBUTTON = &H200
Const BIF_RETURNONLYFSDIRS = &H1

Const FOR_READING = 1
Const FOR_WRITING = 2

Const TAG_BEGIN1 = "#@~^"
Const TAG_BEGIN2 = "=="
Const TAG_BEGIN2_OFFSET = 10
Const TAG_BEGIN_LEN = 12
Const TAG_END = "==^#~@"
Const TAG_END_LEN = 6

Dim argv
Dim wsoShellApp
Dim oFolder
Dim sFolder
Dim sFileSource
Dim sFileDest
Dim fso
Dim fld
Dim fc
Dim bEncoded
Dim fSource
Dim tsSource
Dim tsDest
Dim iNumExamined
Dim iNumProcessed
Dim iNumSkipped

Function Decode(Chaine)

    Dim se,i,c,j,index,ChaineTemp
    Dim tDecode(127)
    Const Combinaison="1231232332321323132311233213233211323231311231321323112331123132"

    Set se=WSCript.CreateObject("Scripting.Encoder")
    For i=9 to 127
        tDecode(i)="JLA"
    Next
    For …
rproffitt commented: This looks to be the code at the link I supplied. Anyhow, it works, which is nice. +12
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Trump has been mobilizing since last October to privatize land that is now held by Native Americans, ostensibly "so that American Indians can pursue development projects that lift them out of poverty". It has absolutely nothing to do with oil and natural gas reserves that may or may not (wink) be under said lands.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

This may be the same thing as 1Third Step from above (I'm not a PHP user) but if any of your fields contain special characters it could screw up the SQL syntax. For example, if the name you are inserting is something like O'Brian then the embedded apostrophe would be the culprit. That's why you should be using parameterized queries.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

For the record, Resilio Sync works between Long Island and Winnipeg and I did not have to consider firewalls. Traffic is encrypted. Synching that is interrrupted by a disconnect is automatically resumed on reconnect. It's worth checking out.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Awesome.

rproffitt commented: Yes, you are. +12