用AutoIt写了一个图片自动归档软件

作者: ldsea 分类: 酷软推荐 发布时间: 2009-09-14 10:40

[size=4]在内网论坛看到有人发帖说需要一个照片自动归档的软件,就是把图片可以按照图片的日期放到相应的文件夹中,感觉用AutoIt这种软件应该挺好实现的,就写了一个,代码如下[/size]
[code]
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt(‘MustDeclareVars’, 1)

AutoPhoto()

Func AutoPhoto()
Local $font,$msg,$Button_1,$radio1,$radio2,$radio3,$radio4,$isOldPhoto,$isCreatDate
$isOldPhoto=True;
$isCreatDate=True;
GUICreate(“图片自动归档程序V1.1–Made By 蓝色天空”,500,200) ; will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW) ; will display an empty dialog box
GUICtrlCreateLabel(“这是一个图片自动归档程序,请把该软件放到图片的同一目录下。”, -1, 10) ; next line
GUICtrlCreateLabel(“选择是否保留原图片和归档日期的方式后,点击按钮后图片即可自动归档”, -1, 30) ; next line
$radio1 = GUICtrlCreateRadio(“保留原图片”, 10, 60, 100, 20)
$radio2 = GUICtrlCreateRadio(“不保留原图片”, 150, 60, 100, 20)
GUIStartGroup()
GUICtrlSetState($radio1, $GUI_CHECKED)
$radio3 = GUICtrlCreateRadio(“按创建日期归档”, 10, 80, 100, 20)
$radio4 = GUICtrlCreateRadio(“按修改日期归档”, 150, 80, 100, 20)
GUIStartGroup()
GUICtrlSetState($radio3, $GUI_CHECKED)
$Button_1 = GUICtrlCreateButton(“开始自动归档”, 10, 120, 100)
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
$isOldPhoto=True;
Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED
$isOldPhoto=False;
Case $msg = $radio3 And BitAND(GUICtrlRead($radio3), $GUI_CHECKED) = $GUI_CHECKED
$isCreatDate=True;
Case $msg = $radio4 And BitAND(GUICtrlRead($radio4), $GUI_CHECKED) = $GUI_CHECKED
$isCreatDate=False;
Case $msg = $Button_1
doAutoPhoto($isOldPhoto,$isCreatDate); Will Run/Open Notepad
EndSelect
WEnd
GUIDelete()
EndFunc   ;==>Example1

Func doAutoPhoto($isOldPhoto,$isCreatDate)
Local $search,$file,$t,$yyyymd
; 显示当前目录中所有文件的文件名
$search = FileFindFirstFile(“*.jpg”)

; 检查搜索是否成功
If $search = -1 Then
MsgBox(0, “错误”, “该目录下已经没有jpg图片文件”)
Exit
EndIf

While 1
$file = FileFindNextFile($search)
If $isCreatDate=True Then
$t = FileGetTime($file, 1)
EndIf
If $isCreatDate=False Then
$t = FileGetTime($file, 0)
EndIf
If Not @error Then
$yyyymd = $t[0] & “年” & $t[1] & “月” & $t[2] & “日”
;MsgBox(0, $file+”的创建日期:”, $yyyymd)
If $isOldPhoto=True Then
FileCopy($file, @ScriptDir & “\” & $yyyymd & “\”, 8)
EndIf
If $isOldPhoto=False Then
FileMove($file, @ScriptDir & “\” & $yyyymd & “\”, 8)
EndIf
;MsgBox(4096, “文件:”, @ScriptDir & “\” & $yyyymd & “\”)
EndIf
If @error Then ExitLoop
;MsgBox(4096, “文件:”, $file)
WEnd
FileClose($search)
MsgBox(64, “海蓝”, “恭喜,所有图片归档完毕”)
EndFunc
[/code]
[size=4]使用时将这个软件和你需要整理的图片放到同一个目录下,然后点击那个“开始自动归档”按钮,选择是否保留原图片,以及是按创建日期归档,还是按修改日期归档。然后点击下面的按钮就好了[/size]
[img][attach]189[/attach][/img]
[size=4]原先目录下有4张图片[/size]
[img][attach]190[/attach][/img]
[size=4]当运行程序后,会变为如下的样子,会按照日期进行归档[/size]
[img][attach]191[/attach][/img]

下载地址:
http://itbrother.com/soft/autoPhoto.rar

发表回复

您的电子邮箱地址不会被公开。