autohotkey实现文件(桌面和任意文件夹)自动整理

用法:选中文件,ctrl+g,自动整理到D盘,通过本实例简单改造可以实现各种自动整理功能,自动化办公的人士可以了解一下!购买文章后,免费给与指导!

用法:选中文件,ctrl+g,自动整理到D盘,通过本实例简单改造可以实现各种自动整理功能,自动化办公的人士可以了解一下!购买文章后,免费给与指导!

[erphpdown]

^g::
	this_path := Selected_Files()        ; 检测选中的文件
	Des_path:="D:\"
	if (this_path)
		loop, Parse, this_path , `n, `r  ; 在 `r 之前指定 `n, 这样可以同时支持对 Windows 和 Unix 文件的解析.
		{
			MoveFilesAndFolders(A_LoopField,Des_path)     ; 移动文件
		}
		else
			MsgBox, 没有选中文件!
return

;移动文件或文件夹
MoveFilesAndFolders(SourcePattern, DestinationFolder, DoOverwrite = false)
; 移动匹配 SourcePattern 的所有文件和文件夹到 DestinationFolder 文件夹中且
; 返回无法移动的文件/文件夹的数目.
{
	; 首先移动所有文件 (不是文件夹):
	FileMove, %SourcePattern%, %DestinationFolder%, %DoOverwrite%
	ErrorCount := ErrorLevel
	; 现在移动所有文件夹:
	loop, %SourcePattern%, 2  ; 2 表示 "只获取文件夹".
	{
		FileMoveDir, %A_LoopFileFullPath%, %DestinationFolder%\%A_LoopFileName%, %DoOverwrite%
		ErrorCount += ErrorLevel
		if ErrorLevel  ; 报告每个出现问题的文件夹名称.
			MsgBox, 文件夹%A_LoopFileFullPath% 不能移动至%DestinationFolder%.
	}
	return ErrorCount
}
;检查是否选中文件
Selected_Files()
{
	;我的电脑句柄
	IfWinActive, ahk_class CabinetWClass
	{
		for window in ComObjCreate("Shell.Application").Windows
			if window.HWND = WinExist("A")
				this_window := window

			; 如果多个项目被选中
		if(this_window.Document.SelectedItems.Count > 1)
		{
			these_files := ""
			for item in this_window.Document.SelectedItems
				these_files .= item.Path . "`n"

			return these_files
		}
	else
		return this_window.Document.FocusedItem.Path
	}

	; 桌面句柄
	if(WinActive("ahk_class Progman") || WinActive("ahk_class WorkerW"))
	{
		ControlGet, selectedFiles, List, Selected Col1, SysListView321, A

		; 如果多个项目被选中
		if InStr(selectedFiles, "`n")
		{
			these_files := ""
			loop, Parse, selectedFiles, `n, `r
				these_files .= A_Desktop . "\" . A_LoopField . "`n"

			return these_files
		}
		else
			return A_Desktop . "\" . selectedFiles
	}
	else
		return false
}

[/erphpdown]

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

autohotkey Dota辅助

2018-1-19 21:00:38

其他

autohotkey kala辅助

2018-1-19 21:49:00

3 条回复 A文章作者 M管理员
  1. 零一

    有用

  2. redoceans

    好用呢。

  3. Leaves

    攒分中。。

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索