Move files of a certain dimension to another folder?

Get help with using AutoHotkey and its commands and hotkeys
unabatedshagie
Posts: 1
Joined: 13 Jan 2017, 14:21

Move files of a certain dimension to another folder?

13 Jan 2017, 14:28

I've got a folder with a bunch of images that get dumped in there regularly.

Would it be possible to create a script that found all images of X and Y dimension and moved them to a new folder and moved all images of A and B dimensions to another?
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Move files of a certain dimension to another folder?

16 Jan 2017, 14:58

Example script to get image details using WIA:

Code: Select all

q:: ;image get info (via WIA)
vDir1 := "C:\Users\" A_UserName "\Pictures"
Loop Files, % vDir1 "\*", % "F"
{
	vPath := A_LoopFileFullPath
	SplitPath, vPath, vName, vDir, vExt, vNameNoExt, vDrive
	break
}

;vPath := A_Desktop "\z my image.png"
;vPath := "C:\Users\" A_UserName "\Pictures\z my image.png"

oImg := ComObjCreate("WIA.ImageFile"), ComObjError(False)
oImg.LoadFile(vPath)
vImgW := vImgH := vFrameCount := vIsAnim := ""
vImgW := oImg.Width
vImgH := oImg.Height
vFrameCount := oImg.FrameCount
vIsAnim := oImg.IsAnimated

vArea := vImgW*vImgH
vWHRatio := vImgW/vImgH
vHWRatio := vImgH/vImgW

vOutput = ;continuation section
(
dir: %vDir%
name: %vName%
width: %vImgW%
height: %vImgH%
area: %vArea%
W/H: %vWHRatio%
H/W: %vHWRatio%
frame count: %vFrameCount%
is animated: %vIsAnim%
)

oImg := "", ComObjError(True)
MsgBox, % vOutput
return
If it doesn't work (after you have tested it against a valid image file), it may be that you need to install WIA.

From ReadMe.txt in wiaautsdk.zip:
To install the Windows Image Acquisition Library v2.0,
copy the contents of this compressed file to a directory on your hard drive.
Copy the wiaaut.chm and wiaaut.chi files to your Help directory (usually located at C:\Windows\Help)
Copy the wiaaut.dll file to your System32 directory (usually located at C:\Windows\System32)
From a Command Prompt in the System32 directory run the following command:
RegSvr32 WIAAut.dll
Other possibilities:
- get command line output from ImageMagick's identify.exe
- use ComObjCreate("Shell.Application") and GetDetailsOf

Useful links:
COM Object Reference [AutoHotkey v1.1+] - Page 8 - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/56987-com-object-reference-autohotkey-v11/page-8#entry407734

WIA - Windows Image Acquisition (1.0.02.00 - 2015-05-03) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=7254
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: divanebaba, Google [Bot], scriptors and 168 guests