I have gone over it, and tested it, and threatened it, and this code actually appears to work:
Code: Select all
; WORKS ON FILES AND FOLDERS
; activates XYplorer window, copies selected item(s) to clipboard, performs chosen rename option and renames item(s)
#SingleInstance force
SendMode Input
IfWinExist, XYplorer
WinActivate, XYplorer
Gui, Add, Text, h-1 section , Select Rename Option
Gui, Add, Checkbox, vRemoveStart , Remove first 5 characters
Gui, Add, Checkbox, vAddDate , Append today's date
Gui, Add, Button, w70 h22 default, Rename
Gui, Add, Button, xp+80 yp w70 h22 , Cancel
Gui, show,,DeRenamer
return
buttonRename:
Gui, submit, nohide
clipboard := ""
WinActivate, XYplorer
Send, ^c
ClipWait
cliptemp := clipboard
saved := cliptemp
If (RemoveStart=1)
gosub RemoveStart
If (AddDate=1)
gosub AddDate
gosub, finish
return
buttonCancel:
GuiEscape:
GuiClose:
exitapp
RemoveStart:
temp := ""
Loop, Parse, cliptemp, `n, `r
{
splitpath, a_loopfield, name, filepath, ext, basename, drive
temp .= "`n" filepath "\" SubStr(Name, 6)
}
cliptemp := ltrim(temp, "`n")
return
AddDate:
temp := ""
FormatTime, dateStamp, YYYYMMDDHH24MISS, -yyyy-MM-dd
Loop, Parse, cliptemp, `n, `r
{
splitpath, a_loopfield, name, filepath, ext, basename, drive
temp .= "`n" filepath "\" BaseName datestamp "." Ext
}
cliptemp := ltrim(temp, "`n")
return
finish:
{
stringsplit, saved, saved, `n, `r
Loop, Parse, cliptemp, `n, `r
{
oldname := saved%a_index%
FileMoveDir, %oldname%, %A_LoopField% , R
saved%a_index% := ""
}
}
return