批量添加文件名添加序号

批量添加文件名添加序号

批量添加文件名添加序号

 

; Generated by AutoGUI 1.3.5a
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
global ID_HistroyList:=""
global ID_Cur:=""
global RegStr:=""
Gui +AlwaysOnTop
Gui Add, GroupBox, x10 y5 w145 h170, 序号类型
Gui Add, Radio, x20 y20 w125 h23 vID_Type gMyFun_FillCurStr, 1,2,...N
Gui Add, Radio, x20 y45 w125 h23 gMyFun_FillCurStr checked, 01,02...99
Gui Add, Radio, x20 y70 w125 h23 gMyFun_FillCurStr, 001,002...999
Gui Add, Radio, x20 y95 w125 h23 gMyFun_FillCurStr, 0001,0002...9999
Gui Add, Radio, x20 y120 w125 h23 gMyFun_FillCurStr, a,b...zzz
Gui Add, Radio, x20 y145 w125 h23 gMyFun_FillCurStr, A,B...ZZZ
Gui Add, GroupBox, x160 y5 w145 h68, 位置
Gui Add, Radio, x170 y20 w125 h23  vID_Pos gMyFun_FillCurStr checked, 文件名首端
Gui Add, Radio, x170 y45 w125 h23 gMyFun_FillCurStr, 文件名尾端
Gui Add, GroupBox, x160 y75 w145 h100, 分隔符
Gui Add, Radio, x170 y95 w80 h23  checked vID_Split gMyFun_FillCurStr, 分隔符:`-
Gui Add, Radio, x170 y120 w80 h23 gMyFun_FillCurStr, 分隔符:`_
Gui Add, Radio, x170 y145 w65 h23 gMyFun_FillCurStr , 自定义:
Gui Add, Edit, x235 y145 w50 h23 vID_SplitStr gMyFun_FillCurStr,
Gui Add, GroupBox, x10 y180 w205 h60, 当前
Gui Font, s15 cBlue
ID_Cur:=1
ID_NowStr:="01-"
Gui Add, Text, x20 y205 w165 vID_NowStr CEnter, %ID_NowStr%
Gui Font
Gui Font, cRed
Gui Add, Text, x220 y195  , 快捷键:`ra:添加`r左右键:改变序号
Gui Font

Gui Show, , 文件名添加序号(By_Kawvin)
MyFun_AddIndex()
return

#IfWinActive ahk_class AutoHotkeyGui
left::
ID_Cur:=ID_Cur-1
if(ID_Cur<1)
ID_Cur:=1
MyFun_FillCurStr()
return

right::
ID_Cur:=ID_Cur+1
MyFun_FillCurStr()
return
#IfWinActive

#IfWinActive ahk_class TTOTAL_CMD	;TC
a::
Gui,Submit,NoHide
MyFun_AddIndex()
return
#IfWinActive

#IfWinActive ahk_class  CabinetWClass	;资管
a::
Gui,Submit,NoHide
MyFun_AddIndex()
return
#IfWinActive


MyFun_AddIndex(){
	;Sleep,50
	MouseGetPos,,,CurWin_id         ;当前鼠标下的进程ID
	WinGet, CurWin_Fullpath,ProcessPath,Ahk_ID %CurWin_id%    ;当前进程的路径
	WinGetTitle, CurWin_Title,Ahk_ID %CurWin_id%    ;当前进程的标题
	CurWin_Saved_ClipBoard := ClipboardAll
	Clipboard =
	Send, ^c
	ClipWait,0.5
	if ( ErrorLevel  )          ;如果没有选择到什么东西,则退出
	{
		Clipboard := CurWin_Saved_ClipBoard    ;还原粘贴板
		CurWin_Saved_ClipBoard =
		return
	}
	MySel=%Clipboard%
	IfInString,MySel,`n
	{
		MsgBox, 64, 提示, 请仅选择一个文件,0.3
		return
	}
	global RegStr
	global ID_HistroyList
	global ID_Pos
	global ID_NowStr
	;检查文件名是否已经存在于历史记录中
	SplitPath,MySel,,MyOutDir,MyOutExt,MyOutNameNoExt
	MyNewName:=""
	IfInString,ID_HistroyList,%MySel%
	{
		if (ID_Pos=1)
			RegStr:="^" . RegStr
		else
			RegStr:=RegStr . "$"
		MyOutNameNoExt:=RegExReplace(MyOutNameNoExt,RegStr,"")
	}
	if (ID_Pos=1)
		MyNewName=%MyOutDir%\%ID_NowStr%%MyOutNameNoExt%.%MyOutExt%
	else
		MyNewName=%MyOutDir%\%MyOutNameNoExt%%ID_NowStr%.%MyOutExt%
	FileMove,%MySel%,%MyNewName%
	ID_HistroyList.=";" MyNewName
	ID_Cur+=1
	MyFun_FillCurStr()
}

MyFun_FillCurStr(){
	global ID_Cur
	global RegStr
	global ID_Type
	global ID_Split
	global ID_Pos
	global ID_NowStr
	Gui,Submit,NoHide
	if (ID_Cur="")
		ID_Cur:=1

	if (ID_Type=1){
		ID_Output:=ID_Cur
		RegStr:="\d"
	} else if (ID_Type=2) {
		ID_Output:=SubStr("000" . ID_Cur,-1)
		RegStr:="\d{2}"
	} else if (ID_Type=3){
		ID_Output:=SubStr("000" . ID_Cur,-2)
		RegStr:="\d{3}"
	} else if (ID_Type=4){
		ID_Output:=SubStr("000" . ID_Cur,-3)
		RegStr:="\d{4}"
	} else if (ID_Type=5) {
		ID_Output:=MyFun_GetExcelColumn(ID_Cur,0)
		RegStr:="^[a-z]{1,3}$"
	} else {
		ID_Output:=MyFun_GetExcelColumn(ID_Cur,1)
		RegStr:="^[A-Z]{1,3}$"
	}

	if(ID_Split=1)
	ID_SplitStr:="-"
	else if (ID_Split=2)
		ID_SplitStr:="_"
	else
		GuiControlGet,ID_SplitStr,,ID_SplitStr
	;~ ID_SplitStr:=ID_SplitStr

	if (ID_Pos=1) {
		ID_NowStr=%ID_Output%%ID_SplitStr%
		RegStr=%RegStr%\%ID_SplitStr%
	} else {
		ID_NowStr=%ID_SplitStr%%ID_Output%
		RegStr=\%ID_SplitStr%%RegStr%
	}
	GuiControl,,ID_NowStr,%ID_NowStr%
}

MyFun_GetExcelColumn(NowID,Caps:=1){
	TemS:=""
	t:=NowID
	loop
	{
		TemS:=  Chr(Mod((t-1),26)+65) . TemS
		t:=Floor((t-1)/26)
	} until t=0
	if !Caps
		StringLower, TemS, TemS
	return	TemS
}

GuiEscape:
GuiClose:
	ExitApp

 

给TA捐赠
共{{data.count}}人
人已捐赠
其他

Kawvin快捷菜单(调用)

2018-1-10 16:13:54

其他教程

托盘图标相关操作对象化及演示

2018-1-11 17:42:44

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
有新私信 私信列表
搜索