Created
May 25, 2025 14:59
-
-
Save erbanku/9ccdba89c3ff21c1a7e1b54cfa771c22 to your computer and use it in GitHub Desktop.
(Windows-IRX9) Created by Cactus with ♥ using GitHub-CLI at Sun 05/25/2025 22:59 +08:00 (1748185170)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires AutoHotkey v2.0 | |
#SingleInstance Force | |
^+s:: | |
{ | |
; Configuration | |
destFolder := "D:\OneDrive\Documents\Snapshots" | |
; Create destination folder if it doesn't exist | |
if !DirExist(destFolder) { | |
try DirCreate(destFolder) | |
catch as e { | |
MsgBox "Failed to create destination folder:`n" destFolder "`nError: " e.Message | |
return | |
} | |
} | |
; Get selected files | |
A_Clipboard := "" | |
Send "^c" | |
if !ClipWait(0.5) { | |
MouseGetPos(&x, &y) | |
ToolTip "Failed to copy to clipboard", x, y + 20 | |
SetTimer () => ToolTip(), -1500 | |
return | |
} | |
; Process each file/folder | |
files := [] | |
loop parse A_Clipboard, "`n", "`r" { | |
path := Trim(A_LoopField) | |
if path = "" ; Skip empty lines | |
continue | |
if FileExist(path) || DirExist(path) | |
files.Push(path) | |
} | |
if files.Length = 0 { | |
MouseGetPos(&mx, &my) | |
ToolTip "No valid files selected", mx, my + 20 | |
SetTimer () => ToolTip(), -1500 | |
return | |
} | |
movedFiles := [] | |
for path in files { | |
timestamp := FormatTime(, "yyyyMMddHHmmss") | |
SplitPath(path, &name, , &ext, &nameNoExt) | |
if DirExist(path) { | |
newName := name ".snapshot." timestamp | |
newPath := destFolder "\" newName | |
try { | |
DirCopy(path, newPath) | |
movedFiles.Push(newPath) | |
} | |
} else { | |
newName := nameNoExt ".snapshot." timestamp "." ext | |
newPath := destFolder "\" newName | |
try { | |
FileCopy(path, newPath) | |
movedFiles.Push(newPath) | |
} | |
} | |
} | |
; Open destination folder if any files were moved | |
if movedFiles.Length > 0 { | |
Run destFolder | |
MouseGetPos(&mx, &my) | |
ToolTip "Moved " movedFiles.Length " items to Snapshots", mx, my + 20 | |
SetTimer () => ToolTip(), -1500 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment