(AutoIt 实例)图片批量重命名小工具,支持jpg、jpeg、png、gif格式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/skywn/article/details/7901277


 


近来无聊写的,用时要先把软件放在图片目录,设置好名字,然后点击立即执行,图片会以 你设置的名字 + 数字  把图片重命名。简单易用。

目前只支持jpg、jpeg、png、gif格式,若想支持更多格式,可以稍加修改。

软件小工具(源代码和执行文件)下载地址:

百度网盘 :链接: http://pan.baidu.com/s/1eQEYuqu 密码: cyvd

【病毒检测结果】

网上测试病毒结果:2/36报毒 已经尽力了   http://r.virscan.org/633f25abc6eb05cb86987f5b8ef6816d 

大家可以用各大工具查杀,不放心的莫下载了。 

AutoIt V3版本编写,很小众的一个脚本语言,软件官方网站 https://www.autoitscript.com/site/  

#cs ----------------------------------------------------------------------------

	AutoIt Version: 3.3.8.1
	Author:         西嘎嘎

	Script Function:
	图片批量重命名小工具

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <File.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

Global $aparts[2] = [180, -1]
Global $data[8] = ["jpg","JPG","jpeg","JPEG","png","PNG","gif","GIF"]

#region ### START Koda GUI section ###
$Form1_1 = GUICreate("图片批量重命名", 265, 142, 570, 303)
$MenuItem1 = GUICtrlCreateMenu("帮助")
$shuoming = GUICtrlCreateMenuItem("说明", $MenuItem1)
$about = GUICtrlCreateMenuItem("关于", $MenuItem1)
$input1 = GUICtrlCreateInput("在这里设置图片名字", 24, 16, 217, 21)
$Button1 = GUICtrlCreateButton("立 即 执 行", 24, 56, 219, 25)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1_1)
GUISetOnEvent($GUI_EVENT_CLOSE, "main")
GUICtrlSetOnEvent($shuoming, "main")
GUICtrlSetOnEvent($about, "main")
GUISetState(@SW_SHOW)
GUICtrlSetOnEvent($Button1, "main")
#endregion ### END Koda GUI section ###
GUIRegisterMsg($WM_ENTERSIZEMOVE, "WM_ENTERSIZEMOVE")
GUIRegisterMsg($WM_EXITSIZEMOVE, "WM_EXITSIZEMOVE")
_GUICtrlStatusBar_SetParts($StatusBar1, $aparts)
_GUICtrlStatusBar_SetText($StatusBar1, "Thank you for using", 0)
_GUICtrlStatusBar_SetText($StatusBar1, "Version  0.1", 1)

While True
	 _ReduceMemory(@AutoItPID)
	Sleep(3000)
WEnd


Func main()
	Switch @GUI_CtrlId
		Case $GUI_EVENT_CLOSE
			FileDelete(@ScriptDir & "\*.au3.tmp")
			Exit
		Case $Button1
			zhixing()
		Case $about
			MsgBox(0 + 8192, "关于", "图片批量修改小工具" & @LF & @LF & "by skywn ")
		Case $shuoming
			MsgBox(0 + 8192, "说明", "将小工具放到相应目录" & @LF & @LF & "支持格式 jpg jpeg png gif ")
	EndSwitch
EndFunc   ;==>main
Func zhixing()
	$picname = GUICtrlRead($input1)
	If $picname = "在这里设置图片名字" Then
		MsgBox(64 + 8192, "Attention", "你还没设图片名字哦 >o<")
	Else

		Local $FileList = _FileListToArray(@ScriptDir)
		If @error Then
			MsgBox(4096, "", "居然出错了 >o<")
			Exit
		EndIf

		$PicNum = $FileList[0]
		$PicBitNum = 0
		While $PicNum >= 1
			$PicNum /= 10
			$PicBitNum +=1
		WEnd

		$PicNameNum = 1
		For $tt = 0 To 6 Step 2
			$PicIndex = 1
			While $PicIndex + $PicNameNum <= $FileList[0] + 1
				If StringRegExp($FileList[$PicIndex], "(.*" & $data[$tt] & ")|(.*" & $data[$tt+1] & ")") Then

						$temp = $PicNameNum
						$PicBitNameNum = 0
						While $temp >=1
							$temp /=10
							$PicBitNameNum +=1
						WEnd
						$PicNameAdd0 = ""
						For $temp = $PicBitNameNum  To $PicBitNum -1
							$PicNameAdd0 &= "0"
						Next

						$check = _ArrayBinarySearch($FileList,$picname & $PicNameAdd0 & $PicNameNum &"."& $data[$tt] ,$PicIndex)
						If $check > $PicIndex Then
							_ArrayDelete($FileList, $check)
							$PicNameNum +=1
						Else
							FileMove(@ScriptDir & "\" & $FileList[$PicIndex], @ScriptDir & "\" & $picname &$PicNameAdd0 & _
							$PicNameNum & "."& $data[$tt], 1)
							_ArrayDelete($FileList, $PicIndex)
							$PicNameNum += 1
						EndIf
				Else
					$PicIndex += 1
				EndIf
			WEnd
		Next
		MsgBox(64 + 8192, "Attention", "已经处理了" & $PicNameNum - 1 & "张图片!")
	EndIf
EndFunc   ;==>zhixing

Func WM_ENTERSIZEMOVE($hWndGUI, $MsgID, $WParam, $LParam)
	WinSetTrans($Form1_1, "", 130)
EndFunc   ;==>WM_ENTERSIZEMOVE

Func WM_EXITSIZEMOVE($hWndGUI, $MsgID, $WParam, $LParam)
	WinSetTrans($Form1_1, "", 255)
EndFunc   ;==>WM_EXITSIZEMOVE

Func _ReduceMemory($i_PID = -1)
	If $i_PID <> -1 Then
			Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
			Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
			DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
	Else
			Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
	EndIf
	Return $ai_Return[0]
EndFunc   ;==>_ReduceMemory

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页