A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Windows 10 » Windows 10 Help Forum
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Sort files by aspect ratio?



 
 
Thread Tools Rate Thread Display Modes
  #31  
Old August 9th 18, 12:48 AM posted to alt.comp.freeware,alt.comp.os.windows-10
Paul[_32_]
external usenet poster
 
Posts: 11,873
Default Sort files by aspect ratio?

Terry Pinnell wrote:

Thanks, will study that asap.

Terry, East Grinstead, UK


Another thing I discovered, is you can add
"Tags" to a file. This doesn't work for PDF
(for PDF, you need to abuse Alternate Streams
to transport such information). Tags do work
for things with EXIF (JPG, TIFF maybe).

The question would be, how to use it ?

tag:16:9

would find all the files tagged as such by you.
So that's how you'd do a search. But it lacks
the features you wanted, like some tolerance
on the 16:9 ratio, like plus or minus 1% tolerance.
You would have to figure that out in advance.
Or fill the field with 1.79 and search for
1.77 OR 1.78 OR 1.79 to have a tolerance about
the 1.78 median.

https://s33.postimg.cc/gbndxb13j/vie...tails_pane.gif

https://s33.postimg.cc/6ecd4jyq7/my_new_tag.gif

Generally speaking, "dumping" the fields seems
to be easier than writing to them.

If you do write to "tags", it seems to be semicolon
separated, and your writer program needs to honor
existing tags and just add new tag values onto the end.
Just destroying the tag entry, might not be good
if you've already been using tags. So rather than
being a tag writer, it has to be a tag editor instead.

Apparently you can add "Comments" to a file, which
is probably yet another EXIF field.

Looking in a hex editor, I could see a test string I
used, being in two places. And I couldn't figure out what
that means, in terms of actual storage schemes. The handling
of the header didn't look particularly "hygienic".

Paul
Ads
  #32  
Old August 9th 18, 01:06 AM posted to alt.comp.freeware,alt.comp.os.windows-10
Paul[_32_]
external usenet poster
 
Posts: 11,873
Default Sort files by aspect ratio?

Terry Pinnell wrote:
Reinhard Skarbal wrote:

In article , lid says...
Terry Pinnell wrote:
Anyone know of a tool or hack that will do something that Win 10 File
Explorer unfortunately cannot: sort a folder of files into aspect ratio
(width/height)?

It's an operation I need quite frequently, such as when trying to
isolate all files with say a 16:9 ratio (to some fine tolerance if
necessary).

Terry, East Grinstead, UK
The third-party examples I could find, seem to
want to "sort" your image collection, into folders,
according to the complex criteria. So instead
of a search as such, they meddle with the collection.

*******

The only thing I can think of, is edit the metadata
on the images, find a field that is searchable
from Windows Search, then write a representative
value into that field in place of the original data.
Then, rebuild the Search Index, to use the new info.

Instead of writing 1.7778 into the field, if the field
was of string type, you could write "16:9" as a text
string.

So maybe in place of Camera, where it says "Nikon",
you could make the Camera "16:9" brand instead :-)

If would be fun if the Search Index was extensible,
but I don't get the impression it's programmable.
And it's limited to a subset of metadata field types.

Maybe it would take some scripting with EXIFTool or
similar. You would want a tool that doesn't mess up
the file system dates as well (which would be an added
complexity).

*******

If you could have, in effect, a File Manager separate
from Windows, with such complex sorting capabilities,
that would be another way to do it.

*******

Running parallel collections is another way to solve it.

Hi Terry

For Windows 10 :
Writing a little script in awk which is using EXIFTOOL will do the job.
This script will create a batch-file for moving (or copying) all
pictures of an certain witdth/height (+- n %) into a new folder.

If you like I will write this script for you in a few days for nothing.
Just send me an email.

Regards
Reinhard



Hi Reinhard,

Thanks, that's very generous of you. Is an awk script simple to run
under Windows? Perhaps we could test that first if you have a basic
script at hand? Something at the 'Hello World' level, with no-brainer
instructions on how to run it?

Did you see my 'macro outline' up-thread?

Terry, East Grinstead, UK


Windows 10 has Bash shell. It has gawk. Gawk
is a version of AWK, with some slight differences.
(There were AWK, NAWK, and GAWK as variants).

Using a script for batch work, might look like this.
I've rigged up the .awk extension, to open in Notepad here.

gawk -f myscript.awk input.txt output.txt

If you download the "Documentation" link here, it
contains a very nice PDF manual for the language.
This manual is every bit as good as the "gray manual"
by the original inventors.

http://gnuwin32.sourceforge.net/packages/gawk.htm

... gawk-3.1.6-1-doc.zip\doc\gawk\3.1.6\gawk-3.1.6\gawk.pdf

The gnuwin32 page has Gawk 3, whereas the Windows 10
Bash shell has Gawk 4. The Bash shell version "puts the wrong
line endings on stuff", and there's a two-line stanza
for the BEGIN clause, to "make it behave nicer".
Bottom line is, if using the Win10 Bash Gawk4,
test carefully and patch up the problem you find.
The gnuwin32 was ported specifically to offer
a taste of the software to Windows users, so
the line endings work out better for you.

The Gawk 3 is very good, quality wise. But one
day when I was processing a 20GB text file, Gawk 3
crashed just before producing output, and the script
I was running then ran fine in Gawk 4. That might
be an example of when to reach for the Bash shell
version.

Paul

  #33  
Old August 9th 18, 10:42 AM posted to alt.comp.freeware,alt.comp.os.windows-10
Reinhard Skarbal[_2_]
external usenet poster
 
Posts: 10
Default Sort files by aspect ratio?

In article , am says...
Dim FSO, arg, sPath, oFol1, sFol, iCount, iTotalImg, iTotal, sMsg
On Error Resume Next

'--Get folder dropped on script or use InputBox:


sPath = WScript.Arguments(0)
Set FSO = CreateObject("Scripting.FileSystemObject")
If sPath = "" Or FSO.FolderExists(sPath) = False Then WScript.Quit

Set oFol1 = FSO.CreateFolder(sPath & "\16-9")
Set oFol1 = Nothing
sFol = sPath & "\16-9\"
iCount = 0

DoSearch sPath
Set FSO = Nothing

sMsg = iTotalImg & " image files found of " & iTotal & " total files."
sMsg = sMsg & vbCrLf & iCount & " fitting ratio requirements"
sMsg = sMsg & " and copied to " & sFol
MsgBox sMsg

Sub DoSearch(FolPath)
Dim SubPath, Fol, oFol, Fils, oFil, Fols, sExt, LRatio
Set oFol = FSO.GetFolder(FolPath)
Set Fils = oFol.Files
If Fils.count 0 Then
For Each oFil in Fils
iTotal = iTotal + 1
sExt = UCase(Right(oFil.Name, 4))
If sExt = ".JPG" Or sExt = ".GIF" Or sExt = ".BMP" Then
iTotalImg = iTotalImg + 1
LRatio = GetRat(oFil.Path)
If Len(LRatio) 0 Then
If FSO.FileExists(sFol & oFil.name) = False Then
FSO.CopyFile oFil.path, sFol & oFil.name, False
iCount = iCount + 1
End If
End If
End If
Next
End If

Set Fols = oFol.SubFolders
If Fols.count 0 Then
For Each Fol in Fols
SubPath = Fol.Path
DoSearch SubPath
Next


Hi mayayana !

How to call your visual basic sript ?
Do I need an additional software for my windows-10 ?

With thanks in advance
Reinhard
  #34  
Old August 9th 18, 01:51 PM posted to alt.comp.freeware,alt.comp.os.windows-10
Mayayana
external usenet poster
 
Posts: 6,438
Default Sort files by aspect ratio?

"Reinhard Skarbal" wrote

| How to call your visual basic sript ?
| Do I need an additional software for my windows-10 ?
|

No, you shouldn't. You just drop a folder
onto it. It uses Windows Script Host, which
has been built in since, I think, Win2000. WSH
(wscript.exe) runs .vbs and .js files by default
and acts as an interpreter for the code. (The
LoadPicture method is actually built into the
WSH, as is CreateObject.) Webpages running
in IE can also run most .vbs script.

It's an intriguing system. With CreateObject,
VBScript can access many system objects
(specifically, and COM object with a Dispatch
interface). That means a script can automate
IE or Word, use ActiveX objects, etc. I've
even written an image editor and scanner utility
using just VBScript in a webpage.

If you have any problems with this script it will
probably be because you accidentally copied a
wordwrapped line from your newsreader. Unlike
javascript, VBS uses line returns to mark the
end of a statement.

The script is safe insofar as it doesn't delete
anything. It just finds BMP/GIF/JPG files
(it will miss ".jpeg" but that can be remedied
if necessary), gets width/height, and if
they're roughly in the right ratio it will copy
them to a newly created subfolder named
"16-9".

There could be complications, though, if one
is running with file restrictions. There's no way
I know of to elevate in a drag/drop operation.
For that the script would need to be written to
accept a typed folder path, so that it could be
right-clicked to run elevated. Restrictions could
be a problem depending on the location you're
dealing with, if you need "permission" to create a
folder and copy files.

If you want to be able to enter the path manually,
you can replace the 5th line of code...

If sPath = "" Or FSO.FolderExists(sPath) = False Then WScript.Quit

.....with this:

If sPath = "" Or FSO.FolderExists(sPath) = False Then
sPath = InputBox("Enter full path of folder with images.", "Find 16:9
images")
End If
If sPath = "" Or FSO.FolderExists(sPath) = False Then WScript.Quit

(That's 4 lines. Watch out for wordwrap in your newsreader.)

That will give you the option to drop a folder or
enter the path. I usually code it that way, anyway.
I was just trying to keep this simple, in case Terry
or others want to make their own edits of the script.
In a public script I'd put a lot of error trapping for
"robustness". For instance, I'd write code to check
whether the folder exists before creating it. But this
is meant to be a simple script and it does a simple,
safe operation, so I tried to keep it simple.

You also might want to alter the ratio spec. As written,
it divides the height by 9, multiplies that by 16, then
calls it a match if that number is within 95% and 105%
of the width. If you look at the code you'll see it's easy
to change those numbers, to look for, say, a 6:4 ratio, to
increase or decrease the tolerance range, etc. There
may also be another way to check the ratio. This method
seemed simplest to me, but I didn't research options.


  #35  
Old August 9th 18, 02:35 PM posted to alt.comp.freeware,alt.comp.os.windows-10
Terry Pinnell[_3_]
external usenet poster
 
Posts: 732
Default Sort files by aspect ratio?

Paul wrote:

Terry Pinnell wrote:
Reinhard Skarbal wrote:

In article , lid says...
Terry Pinnell wrote:
Anyone know of a tool or hack that will do something that Win 10 File
Explorer unfortunately cannot: sort a folder of files into aspect ratio
(width/height)?

It's an operation I need quite frequently, such as when trying to
isolate all files with say a 16:9 ratio (to some fine tolerance if
necessary).

Terry, East Grinstead, UK
The third-party examples I could find, seem to
want to "sort" your image collection, into folders,
according to the complex criteria. So instead
of a search as such, they meddle with the collection.

*******

The only thing I can think of, is edit the metadata
on the images, find a field that is searchable
from Windows Search, then write a representative
value into that field in place of the original data.
Then, rebuild the Search Index, to use the new info.

Instead of writing 1.7778 into the field, if the field
was of string type, you could write "16:9" as a text
string.

So maybe in place of Camera, where it says "Nikon",
you could make the Camera "16:9" brand instead :-)

If would be fun if the Search Index was extensible,
but I don't get the impression it's programmable.
And it's limited to a subset of metadata field types.

Maybe it would take some scripting with EXIFTool or
similar. You would want a tool that doesn't mess up
the file system dates as well (which would be an added
complexity).

*******

If you could have, in effect, a File Manager separate
from Windows, with such complex sorting capabilities,
that would be another way to do it.

*******

Running parallel collections is another way to solve it.
Hi Terry

For Windows 10 :
Writing a little script in awk which is using EXIFTOOL will do the job.
This script will create a batch-file for moving (or copying) all
pictures of an certain witdth/height (+- n %) into a new folder.

If you like I will write this script for you in a few days for nothing.
Just send me an email.

Regards
Reinhard



Hi Reinhard,

Thanks, that's very generous of you. Is an awk script simple to run
under Windows? Perhaps we could test that first if you have a basic
script at hand? Something at the 'Hello World' level, with no-brainer
instructions on how to run it?

Did you see my 'macro outline' up-thread?

Terry, East Grinstead, UK


Windows 10 has Bash shell. It has gawk. Gawk
is a version of AWK, with some slight differences.
(There were AWK, NAWK, and GAWK as variants).

Using a script for batch work, might look like this.
I've rigged up the .awk extension, to open in Notepad here.

gawk -f myscript.awk input.txt output.txt

If you download the "Documentation" link here, it
contains a very nice PDF manual for the language.
This manual is every bit as good as the "gray manual"
by the original inventors.

http://gnuwin32.sourceforge.net/packages/gawk.htm

... gawk-3.1.6-1-doc.zip\doc\gawk\3.1.6\gawk-3.1.6\gawk.pdf

The gnuwin32 page has Gawk 3, whereas the Windows 10
Bash shell has Gawk 4. The Bash shell version "puts the wrong
line endings on stuff", and there's a two-line stanza
for the BEGIN clause, to "make it behave nicer".
Bottom line is, if using the Win10 Bash Gawk4,
test carefully and patch up the problem you find.
The gnuwin32 was ported specifically to offer
a taste of the software to Windows users, so
the line endings work out better for you.

The Gawk 3 is very good, quality wise. But one
day when I was processing a 20GB text file, Gawk 3
crashed just before producing output, and the script
I was running then ran fine in Gawk 4. That might
be an example of when to reach for the Bash shell
version.

Paul


Thanks, very helpful. With AWK/GAWK in mind I may well have to abandon
my recent resolution ("Resist learning new stuff and focus on creative
work with the stuff I know") as AWK/GAWK/NAWK looks rather useful.

But I'm always cheerful about building on others' know-how in copy/paste
mode. Which is what I'm about to do by trying both Mayayana's and
Reinhard's respective VBS and AWK scripts.

Still always more satisfying to do it myself though, so I'm still
looking at my macro approach ;-)

Terry, East Grinstead, UK
  #36  
Old August 9th 18, 03:57 PM posted to alt.comp.freeware,alt.comp.os.windows-10
Terry Pinnell[_3_]
external usenet poster
 
Posts: 732
Default Sort files by aspect ratio?

"Mayayana" wrote:

"Terry Pinnell" wrote

| Thanks, will study that asap.
|
If you're interested in working on it you can try this:
(Watch out for wordwrap.) Paste the following into
Notepad, save as a .vbs file. Drop any folder onto it.
You should get a folder created inside with copies of
all images found within 5% of 16/9 ratio that are JPG,
GIF, or BMP. It will also search subfolders.

One one run it didn't pick up a very large image.
I'm not sure if there was a reason for that. If it
turns out to be a problem the script might need
a pause built in for copying big files.

There's not much here for error trapping. You
must drop a valid folder. It also uses the simple
LoadPicture method. Code could be added to
deal with PNGs but that would cost extra.


' --- begin script ----------------
Dim FSO, arg, sPath, oFol1, sFol, iCount, iTotalImg, iTotal, sMsg
On Error Resume Next

'--Get folder dropped on script or use InputBox:


sPath = WScript.Arguments(0)
Set FSO = CreateObject("Scripting.FileSystemObject")
If sPath = "" Or FSO.FolderExists(sPath) = False Then WScript.Quit

Set oFol1 = FSO.CreateFolder(sPath & "\16-9")
Set oFol1 = Nothing
sFol = sPath & "\16-9\"
iCount = 0

DoSearch sPath
Set FSO = Nothing

sMsg = iTotalImg & " image files found of " & iTotal & " total files."
sMsg = sMsg & vbCrLf & iCount & " fitting ratio requirements"
sMsg = sMsg & " and copied to " & sFol
MsgBox sMsg

Sub DoSearch(FolPath)
Dim SubPath, Fol, oFol, Fils, oFil, Fols, sExt, LRatio
Set oFol = FSO.GetFolder(FolPath)
Set Fils = oFol.Files
If Fils.count 0 Then
For Each oFil in Fils
iTotal = iTotal + 1
sExt = UCase(Right(oFil.Name, 4))
If sExt = ".JPG" Or sExt = ".GIF" Or sExt = ".BMP" Then
iTotalImg = iTotalImg + 1
LRatio = GetRat(oFil.Path)
If Len(LRatio) 0 Then
If FSO.FileExists(sFol & oFil.name) = False Then
FSO.CopyFile oFil.path, sFol & oFil.name, False
iCount = iCount + 1
End If
End If
End If
Next
End If

Set Fols = oFol.SubFolders
If Fols.count 0 Then
For Each Fol in Fols
SubPath = Fol.Path
DoSearch SubPath
Next
End If
Set Fols = Nothing

Set Fils = Nothing
Set oFol = Nothing

End Sub

Function GetRat(PicPath)
Dim Pic, arg1, PPI, Ht, Wd, Ht9, Wd16
On Error Resume Next
GetRat = ""
PPI = 96 'for large fonts setting use 120.
Set Pic = LoadPicture(PicPath)
Ht = CInt((PPI * Pic.height) / 2540)
Wd = CInt((PPI * Pic.width) / 2540)
Set Pic = Nothing
If Ht Wd Then Exit Function
Ht9 = Ht / 9
Wd16 = Ht9 * 16
If (Wd16 (.95 * Wd)) And (Wd16 (1.05 * Wd)) Then GetRat = PicPath
End Function


Excellent, that works a treat, many thanks!

I've run it on a couple of test folders (all JPGs) one of a 100 and the
other of 31. I found one minor flaw that should be easy to fix -
although I baulked at attempting it myself ;-) In both cases it reported
the total number of image files too high, the difference being the
number of 169's. iCount is presumably getting included in iTotal and
iTotalImg?

Am I right that I would modify just the line
If (Wd16 (.95 * Wd)) And (Wd16 (1.05 * Wd)) Then GetRat = PicPath
to change the percentage tolerance to a lower value than 5%?

And just the previous two lines to test for ARs other than 16:9?

Are there alternative ways to run it apart from dragging the folder onto
the script in FE?

Much appreciate your going to the trouble of writing that.

Terry, East Grinstead, UK
  #37  
Old August 9th 18, 06:50 PM posted to alt.comp.freeware,alt.comp.os.windows-10
Terry Pinnell[_3_]
external usenet poster
 
Posts: 732
Default Sort files by aspect ratio?

Terry Pinnell wrote:

Excellent, that works a treat, many thanks!

I've run it on a couple of test folders (all JPGs) one of a 100 and the
other of 31. I found one minor flaw that should be easy to fix -
although I baulked at attempting it myself ;-) In both cases it reported
the total number of image files too high, the difference being the
number of 169's. iCount is presumably getting included in iTotal and
iTotalImg?

Am I right that I would modify just the line
If (Wd16 (.95 * Wd)) And (Wd16 (1.05 * Wd)) Then GetRat = PicPath
to change the percentage tolerance to a lower value than 5%?

And just the previous two lines to test for ARs other than 16:9?

Are there alternative ways to run it apart from dragging the folder onto
the script in FE?

Much appreciate your going to the trouble of writing that.

Terry, East Grinstead, UK


I've now also written my own with Macro Express Pro, saving ALL files
into a new folder with names prefixed with the AR rounded to 3 dp, like
this:

0.664-20020501-0929021.JPG
1.344-Puglia-047.JPG
1.432-20020330-Janet-Blagdon2.JPG
1.524-Puglia-112.jpg
1.777-Puglia-054.jpg
1.777-Puglia-072.jpg
1.778-Puglia-068.jpg
1.778-Puglia-074.jpg
1.778-Puglia-078.jpg
1.786-Puglia-052.jpg
etc.

But it's glacially slow. I could probably improve it a bit, but it's
currently taking about 5 s per image! In striking contrast your VBS
processed 31 images in 5 s and 100 in 14 s. So although my presentation
method is arguably more useful for my purposes (a quick sort on Name
lets me see and extract ARs like 16:9, 4:3, 3:2, 3:4, etc) it really is
no contest!

Neat work, thanks again.

Terry, East Grinstead, UK
  #38  
Old August 9th 18, 08:51 PM posted to alt.comp.freeware,alt.comp.os.windows-10
B. R. 'BeAr' Ederson
external usenet poster
 
Posts: 8
Default Sort files by aspect ratio?

On Tue, 07 Aug 2018 12:27:21 +0100, Terry Pinnell wrote:

Anyone know of a tool or hack that will do something that Win 10 File
Explorer unfortunately cannot: sort a folder of files into aspect ratio
(width/height)?


Although I still think, Dimensions2Folder is best suited for your needs,

http://www.dcmembers.com/skwire/down...ions-2-folders

maybe you like Arti from the same author even better:

http://www.dcmembers.com/skwire/download/arti

Be sure to (really) try both of them. They are no-install portable.

F-Up set to acf.
BeAr
--
================================================== =========================
= What do you mean with: "Perfection is always an illusion"? =
================================================== =============--(Oops!)===
  #39  
Old August 9th 18, 11:07 PM posted to alt.comp.freeware,alt.comp.os.windows-10
Terry Pinnell[_3_]
external usenet poster
 
Posts: 732
Default Sort files by aspect ratio?

"B. R. 'BeAr' Ederson" wrote:

On Tue, 07 Aug 2018 12:27:21 +0100, Terry Pinnell wrote:

Anyone know of a tool or hack that will do something that Win 10 File
Explorer unfortunately cannot: sort a folder of files into aspect ratio
(width/height)?


Although I still think, Dimensions2Folder is best suited for your needs,

http://www.dcmembers.com/skwire/down...ions-2-folders

maybe you like Arti from the same author even better:

http://www.dcmembers.com/skwire/download/arti

Be sure to (really) try both of them. They are no-install portable.

F-Up set to acf.
BeAr


Thanks BeAr, Dimensions2Folder is a nice tool and it does indeed do what
I want. And on brief acquaintance it has the advantage of being over
three times faster than Mayayana's VBS script. For example, my test
folder of 100 files took 4 s.

Did you try Arti? It appears to be unstable here in Version 1803 (build
17134.167). A few seconds after dragging a folder or multiple files, it
closes unceremoniously.

Terry, East Grinstead, UK
  #40  
Old August 9th 18, 11:39 PM posted to alt.comp.freeware,alt.comp.os.windows-10
Mayayana
external usenet poster
 
Posts: 6,438
Default Sort files by aspect ratio?

"Terry Pinnell" wrote

| Excellent, that works a treat, many thanks!
|

Good. It's not alway feasible to make a generic
script that's useful.

| I've run it on a couple of test folders (all JPGs) one of a 100 and the
| other of 31. I found one minor flaw that should be easy to fix -
| although I baulked at attempting it myself ;-) In both cases it reported
| the total number of image files too high, the difference being the
| number of 169's. iCount is presumably getting included in iTotal and
| iTotalImg?
|
Woops. I see what happened. It recurses through
subfolders, so if there are, say, 10 169s in the parent
folder they'll be copied to the 16-9 folder. Then the
recursion will process the 16-9 folder. It's harmless,
but a waste of time and makes for a faulty count.
Here's the fix. Find this section:

Set Fols = oFol.SubFolders
If Fols.count 0 Then
For Each Fol in Fols
SubPath = Fol.Path
If InStr(SubPath, "16-9") = 0 Then 'new
DoSearch SubPath
End If 'new
Next
End If
Set Fols = Nothing

Replace it with the version above. The two lines
marked with 'new were added to exempt processing
of the 16-9 folder.


| Am I right that I would modify just the line
| If (Wd16 (.95 * Wd)) And (Wd16 (1.05 * Wd)) Then GetRat = PicPath
| to change the percentage tolerance to a lower value than 5%?
|

Yes. .98 and 1.02 would give you a 2%
range, for instance. It checking the value of
the actual width against (height / 9) * 16.

| And just the previous two lines to test for ARs other than 16:9?
|

Yes. Change the 16 and 9. You could also make
it multiple: Check whether it's 16:9 or 5:4
or 7:5, etc. Once you've retrieved w/h that extra work
would be negligible.

Also, for anyone who has
trouble, make sure you don't have large fonts set.
I think this is the Registry value to find that setting,
if necessary:

HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI

It sounds like that's not something that you,
specifically, need to be concerned with.

| Are there alternative ways to run it apart from dragging the folder onto
| the script in FE?
|
FE? See the version I posted for Reinhard. It
provides the option to double-click the .vbs
and enter a path.
There are lots of ways to do it. You could put it
in an HTA to get a GUI. You could hardcode one
or more folder paths... I was just writing something
that's adaptable. You might want to process
G:\ while someone else wants to process their
docs folder and D:\photos. The only way to make
it adaptable is to not hardcode it.
Likewise, you could have it write a list rather
than copying files. The nice thing about script is
that it's easy to customize and it's great for this
kind of automation. But the down side, of course,
is that you have to know how to write it if you
want it customized to your needs.

It could also be quite a bit faster by just reading
the file headers to get width/height. The method I
used is like reading a book to find out a specific fact,
while reading headers is more like looking it up in
the index and reading only the relevant page. But
the method I used is very simple and reasonably
fast for most purposes.

I don'ty know why MEP would be so slow. I guess
it really depends on what steps you're using rather
than on MEP's speed. If you automate something like
picking through EXIF data or have to actually load/display
the image then that will be very inefficient.


  #41  
Old August 10th 18, 03:21 AM posted to alt.comp.freeware,alt.comp.os.windows-10
Paul[_32_]
external usenet poster
 
Posts: 11,873
Default Sort files by aspect ratio?

Terry Pinnell wrote:
"B. R. 'BeAr' Ederson" wrote:

On Tue, 07 Aug 2018 12:27:21 +0100, Terry Pinnell wrote:

Anyone know of a tool or hack that will do something that Win 10 File
Explorer unfortunately cannot: sort a folder of files into aspect ratio
(width/height)?

Although I still think, Dimensions2Folder is best suited for your needs,

http://www.dcmembers.com/skwire/down...ions-2-folders

maybe you like Arti from the same author even better:

http://www.dcmembers.com/skwire/download/arti

Be sure to (really) try both of them. They are no-install portable.

F-Up set to acf.
BeAr


Thanks BeAr, Dimensions2Folder is a nice tool and it does indeed do what
I want. And on brief acquaintance it has the advantage of being over
three times faster than Mayayana's VBS script. For example, my test
folder of 100 files took 4 s.

Did you try Arti? It appears to be unstable here in Version 1803 (build
17134.167). A few seconds after dragging a folder or multiple files, it
closes unceremoniously.

Terry, East Grinstead, UK


A faster way to get the picture information, would be
to consult Windows.edb instead.

This is a tech demo, not a complete application.
It generates a CSV file which shows all the
images on the path in the SCOPE. Adjust the SCOPE
string to reflect where your image collection is on
disk. If you set the scope to "C:\" then you'll
pick up every 1x1 pixel picture ever invented :-)

What this is doing, is leveraging the three hours spent
by the Windows Search indexer, on your image collection
already.

Yes, you've seen this script before, in a previous
question. I just tweaked it a little bit. You run this
from a "regular user" Powershell. cd to the directory
containing the script, then run it. Powershell will not
run a file from the current working directory, unless
the dot is in front, as shown. I'm not a Powershell
expert, so am not going to be able to dig you out
of trouble all that easily. I'm a "copy/paste expert" :-/
If I can do it with copy/paste, I will.

########### ./little_bobby_tables2.ps1 ################################
#
# Inspiration: https://www.petri.com/how-to-query-t...and-powershell
#
# (Commented out text, is either outright failed stuff, or variants you can test)
#
# At the bottom line, pick a more imaginative filename...
#
# Hint - the less formatting you do in PowerShell, the faster the script runs.
#
# The CSV can be pulled into Excel, LibreOffice Calc, or Notepad.
#
################################################## ####################

$sql = "SELECT System.ItemFolderPathDisplay, `
System.ItemName, `
System.Image.HorizontalSize, `
System.Image.VerticalSize FROM SYSTEMINDEX `
WHERE System.Image.HorizontalSize0 AND `
System.Image.VerticalSize0 AND `
SCOPE='C:\users\Terry Pinnell\Downloads'"

$provider = "provider=search.collatordso;extended properties=’application=windows’;"

$connector = new-object system.data.oledb.oledbdataadapter -argument $sql, $provider

$dataset = new-object system.data.dataset

if ($connector.fill($dataset)) { $dataset.tables[0] | Export-CSV little.bobby.tables.4.csv }

########### end of ./little_bobby_tables2.ps1 ##########################

Paul
  #42  
Old August 10th 18, 04:59 AM posted to alt.comp.freeware,alt.comp.os.windows-10
B. R. 'BeAr' Ederson
external usenet poster
 
Posts: 8
Default Sort files by aspect ratio?

On Thu, 09 Aug 2018 23:07:52 +0100, Terry Pinnell wrote:

Did you try Arti? It appears to be unstable here in Version 1803 (build
17134.167). A few seconds after dragging a folder or multiple files, it
closes unceremoniously.


Tested on Win7 and it behaved well. Maybe you try it with less files
and open them by selecting a folder (subfolders option set if needed).
So you could test the functionality, like sorting by aspect ratio,
opening images with the standard program registered for the extension,
copying files, creating a *.csv.

If you find it better suited for your needs than Dimensions2Folders
(likely not), you can inform Jody Holmes about the problem on Win10.
Maybe he can fix it up. Please note, that Jody might appreciate a
donation for this. (And for any extensive usage of his program.) He
is an active part of the Donation Coder community; the donations seem
to be important to him as a kind of respect for his work.

F-Up set to acf.
BeAr
--
================================================== =========================
= What do you mean with: "Perfection is always an illusion"? =
================================================== =============--(Oops!)===
  #43  
Old August 10th 18, 11:38 AM posted to alt.comp.freeware,alt.comp.os.windows-10
Terry Pinnell[_3_]
external usenet poster
 
Posts: 732
Default Sort files by aspect ratio?

"Mayayana" wrote:

"Terry Pinnell" wrote

| Excellent, that works a treat, many thanks!
|

Good. It's not alway feasible to make a generic
script that's useful.

| I've run it on a couple of test folders (all JPGs) one of a 100 and the
| other of 31. I found one minor flaw that should be easy to fix -
| although I baulked at attempting it myself ;-) In both cases it reported
| the total number of image files too high, the difference being the
| number of 169's. iCount is presumably getting included in iTotal and
| iTotalImg?
|
Woops. I see what happened. It recurses through
subfolders, so if there are, say, 10 169s in the parent
folder they'll be copied to the 16-9 folder. Then the
recursion will process the 16-9 folder. It's harmless,
but a waste of time and makes for a faulty count.
Here's the fix. Find this section:

Set Fols = oFol.SubFolders
If Fols.count 0 Then
For Each Fol in Fols
SubPath = Fol.Path
If InStr(SubPath, "16-9") = 0 Then 'new
DoSearch SubPath
End If 'new
Next
End If
Set Fols = Nothing

Replace it with the version above. The two lines
marked with 'new were added to exempt processing
of the 16-9 folder.


Thanks a bunch. Duly edited but my 100 images (99 JPGs plus a BMP) are
now reported as 99 out of 100. Correct 169 result.


| Am I right that I would modify just the line
| If (Wd16 (.95 * Wd)) And (Wd16 (1.05 * Wd)) Then GetRat = PicPath
| to change the percentage tolerance to a lower value than 5%?
|

Yes. .98 and 1.02 would give you a 2%
range, for instance. It checking the value of
the actual width against (height / 9) * 16.

| And just the previous two lines to test for ARs other than 16:9?
|

Yes. Change the 16 and 9. You could also make
it multiple: Check whether it's 16:9 or 5:4
or 7:5, etc. Once you've retrieved w/h that extra work
would be negligible.

Also, for anyone who has
trouble, make sure you don't have large fonts set.
I think this is the Registry value to find that setting,
if necessary:

HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI

It sounds like that's not something that you,
specifically, need to be concerned with.

| Are there alternative ways to run it apart from dragging the folder onto
| the script in FE?
|
FE? See the version I posted for Reinhard. It
provides the option to double-click the .vbs
and enter a path.
There are lots of ways to do it. You could put it
in an HTA to get a GUI. You could hardcode one
or more folder paths... I was just writing something
that's adaptable. You might want to process
G:\ while someone else wants to process their
docs folder and D:\photos. The only way to make
it adaptable is to not hardcode it.
Likewise, you could have it write a list rather
than copying files. The nice thing about script is
that it's easy to customize and it's great for this
kind of automation. But the down side, of course,
is that you have to know how to write it if you
want it customized to your needs.

It could also be quite a bit faster by just reading
the file headers to get width/height. The method I
used is like reading a book to find out a specific fact,
while reading headers is more like looking it up in
the index and reading only the relevant page. But
the method I used is very simple and reasonably
fast for most purposes.


I'll experiment.

I don'ty know why MEP would be so slow. I guess
it really depends on what steps you're using rather
than on MEP's speed. If you automate something like
picking through EXIF data or have to actually load/display
the image then that will be very inefficient.


MEP sometimes introduces inexplicably long delays between commands that
should be 'immediate'. But also, of course, merely simulating the steps
I would perform to accomplish is a major factor. In case you missed my
earlier post, here's a paste of how I planned to do it (and which I
implemented):

--------------------
Failing anything simpler (and especially faster), I may do it the
long-winded way with Macro Express Pro:
https://www.dropbox.com/s/tejhxmfa6a...pect.jpg?raw=1

1. Open file in IrfanView
2. Tap the 'i' key to display its properties
3. Select the 'Current size' field
4. Edit that to get a prefix like '1.333', 1.778, etc. (Need to avoid a
semi-colon. And a decimal value has the advantage of showing me at a
glance if AR is close to a standard. Or I could add that to my macro
after providing a percentage tolerance.)
5. Still in IrfanView, use F2 to change file name, e.g to
'1.333-Pugia-006.jpg' in the example shown.
6. Save that to a new folder.
7. Repeat for all files in the source folder.

A sort on Name with FE in the new folder should then give me what I
need.
--------------------

Note that it currently saves the renamed files to a *fixed* folder for
simplicity, not to a subfolder of the original.

During this entire process I cannot do any other work. The macro is
doing everything that I would do manually, including opening each file
in IrfanView (and displaying it), and its Properties window, etc, etc.
(But no reliance on EXIF, which - even for one of my own photos - might
no longer exist.)

Significant effort might get that 5s per image down to say 3s. No point,
given the much faster methods from your VBS script and (even faster!)
from BeAr's solution.

Terry, East Grinstead, UK

  #44  
Old August 10th 18, 12:04 PM posted to alt.comp.freeware,alt.comp.os.windows-10
Terry Pinnell[_3_]
external usenet poster
 
Posts: 732
Default Sort files by aspect ratio?

Paul wrote:

Terry Pinnell wrote:
"B. R. 'BeAr' Ederson" wrote:

On Tue, 07 Aug 2018 12:27:21 +0100, Terry Pinnell wrote:

Anyone know of a tool or hack that will do something that Win 10 File
Explorer unfortunately cannot: sort a folder of files into aspect ratio
(width/height)?
Although I still think, Dimensions2Folder is best suited for your needs,

http://www.dcmembers.com/skwire/down...ions-2-folders

maybe you like Arti from the same author even better:

http://www.dcmembers.com/skwire/download/arti

Be sure to (really) try both of them. They are no-install portable.

F-Up set to acf.
BeAr


Thanks BeAr, Dimensions2Folder is a nice tool and it does indeed do what
I want. And on brief acquaintance it has the advantage of being over
three times faster than Mayayana's VBS script. For example, my test
folder of 100 files took 4 s.

Did you try Arti? It appears to be unstable here in Version 1803 (build
17134.167). A few seconds after dragging a folder or multiple files, it
closes unceremoniously.

Terry, East Grinstead, UK


A faster way to get the picture information, would be
to consult Windows.edb instead.

This is a tech demo, not a complete application.
It generates a CSV file which shows all the
images on the path in the SCOPE. Adjust the SCOPE
string to reflect where your image collection is on
disk. If you set the scope to "C:\" then you'll
pick up every 1x1 pixel picture ever invented :-)

What this is doing, is leveraging the three hours spent
by the Windows Search indexer, on your image collection
already.

Yes, you've seen this script before, in a previous
question. I just tweaked it a little bit. You run this
from a "regular user" Powershell. cd to the directory
containing the script, then run it. Powershell will not
run a file from the current working directory, unless
the dot is in front, as shown. I'm not a Powershell
expert, so am not going to be able to dig you out
of trouble all that easily. I'm a "copy/paste expert" :-/
If I can do it with copy/paste, I will.

########### ./little_bobby_tables2.ps1 ################################
#
# Inspiration: https://www.petri.com/how-to-query-t...and-powershell
#
# (Commented out text, is either outright failed stuff, or variants you can test)
#
# At the bottom line, pick a more imaginative filename...
#
# Hint - the less formatting you do in PowerShell, the faster the script runs.
#
# The CSV can be pulled into Excel, LibreOffice Calc, or Notepad.
#
################################################# #####################

$sql = "SELECT System.ItemFolderPathDisplay, `
System.ItemName, `
System.Image.HorizontalSize, `
System.Image.VerticalSize FROM SYSTEMINDEX `
WHERE System.Image.HorizontalSize0 AND `
System.Image.VerticalSize0 AND `
SCOPE='C:\users\Terry Pinnell\Downloads'"

$provider = "provider=search.collatordso;extended properties=’application=windows’;"

$connector = new-object system.data.oledb.oledbdataadapter -argument $sql, $provider

$dataset = new-object system.data.dataset

if ($connector.fill($dataset)) { $dataset.tables[0] | Export-CSV little.bobby.tables.4.csv }

########### end of ./little_bobby_tables2.ps1 ##########################

Paul


Thanks, but I'm having trouble at the first hurdle. Haven't enough time
right now to plunge into learning the basics of Powershell. But as a
start I copy pasted your entire text to my editor and saved it in
C:\Users\terry\Dropbox\Scripts as
../little_bobby_tables2.ps1
(I assumed that's a lower case letter 'l', not the number '1'? But I've
tried both. Neither look like legitimate filenames...

I opened a PS window. What should I now type on the command line to run
that script file? Or how should I rename it?

Terry, East Grinstead, UK
  #45  
Old August 10th 18, 12:24 PM posted to alt.comp.freeware,alt.comp.os.windows-10
Paul[_32_]
external usenet poster
 
Posts: 11,873
Default Sort files by aspect ratio?

Terry Pinnell wrote:
Paul wrote:

Terry Pinnell wrote:
"B. R. 'BeAr' Ederson" wrote:

On Tue, 07 Aug 2018 12:27:21 +0100, Terry Pinnell wrote:

Anyone know of a tool or hack that will do something that Win 10 File
Explorer unfortunately cannot: sort a folder of files into aspect ratio
(width/height)?
Although I still think, Dimensions2Folder is best suited for your needs,

http://www.dcmembers.com/skwire/down...ions-2-folders

maybe you like Arti from the same author even better:

http://www.dcmembers.com/skwire/download/arti

Be sure to (really) try both of them. They are no-install portable.

F-Up set to acf.
BeAr
Thanks BeAr, Dimensions2Folder is a nice tool and it does indeed do what
I want. And on brief acquaintance it has the advantage of being over
three times faster than Mayayana's VBS script. For example, my test
folder of 100 files took 4 s.

Did you try Arti? It appears to be unstable here in Version 1803 (build
17134.167). A few seconds after dragging a folder or multiple files, it
closes unceremoniously.

Terry, East Grinstead, UK

A faster way to get the picture information, would be
to consult Windows.edb instead.

This is a tech demo, not a complete application.
It generates a CSV file which shows all the
images on the path in the SCOPE. Adjust the SCOPE
string to reflect where your image collection is on
disk. If you set the scope to "C:\" then you'll
pick up every 1x1 pixel picture ever invented :-)

What this is doing, is leveraging the three hours spent
by the Windows Search indexer, on your image collection
already.

Yes, you've seen this script before, in a previous
question. I just tweaked it a little bit. You run this
from a "regular user" Powershell. cd to the directory
containing the script, then run it. Powershell will not
run a file from the current working directory, unless
the dot is in front, as shown. I'm not a Powershell
expert, so am not going to be able to dig you out
of trouble all that easily. I'm a "copy/paste expert" :-/
If I can do it with copy/paste, I will.

########### ./little_bobby_tables2.ps1 ################################
#
# Inspiration: https://www.petri.com/how-to-query-t...and-powershell
#
# (Commented out text, is either outright failed stuff, or variants you can test)
#
# At the bottom line, pick a more imaginative filename...
#
# Hint - the less formatting you do in PowerShell, the faster the script runs.
#
# The CSV can be pulled into Excel, LibreOffice Calc, or Notepad.
#
################################################## ####################

$sql = "SELECT System.ItemFolderPathDisplay, `
System.ItemName, `
System.Image.HorizontalSize, `
System.Image.VerticalSize FROM SYSTEMINDEX `
WHERE System.Image.HorizontalSize0 AND `
System.Image.VerticalSize0 AND `
SCOPE='C:\users\Terry Pinnell\Downloads'"

$provider = "provider=search.collatordso;extended properties=’application=windows’;"

$connector = new-object system.data.oledb.oledbdataadapter -argument $sql, $provider

$dataset = new-object system.data.dataset

if ($connector.fill($dataset)) { $dataset.tables[0] | Export-CSV little.bobby.tables.4.csv }

########### end of ./little_bobby_tables2.ps1 ##########################

Paul


Thanks, but I'm having trouble at the first hurdle. Haven't enough time
right now to plunge into learning the basics of Powershell. But as a
start I copy pasted your entire text to my editor and saved it in
C:\Users\terry\Dropbox\Scripts as
./little_bobby_tables2.ps1
(I assumed that's a lower case letter 'l', not the number '1'? But I've
tried both. Neither look like legitimate filenames...

I opened a PS window. What should I now type on the command line to run
that script file? Or how should I rename it?

Terry, East Grinstead, UK


You can rename it to "powertst.ps1" if you want.
That's Pee Esse One as a file extension.

I didn't invent that extension. Microsoft did.

1) Open a Powershell window.

2) .\powertst.ps1

Then open the output file that's been dumped
into the same directory. You could change the
name in the script from "little.bobby.tables.4.csv"
if you want. You could use "powertst.csv" if you
wanted, to make the name shorter.

Paul
 




Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off






All times are GMT +1. The time now is 07:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.