AutoHotkey: Inplace rename facilities

From TotalcmdWiki
Revision as of 18:43, 6 June 2008 by White (talk | contribs) (Added category AutoHotkey scripts)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Set of small AHK scripts allowing to perform different tasks (uppercase, lowercase, add or remove underscore ... from the highlighted file in Inplace rename field). It can also be used anywhere else just highlight the text you want to modify and press WinKey+1 or WinKey+2 ...

All lowercase
;#1 -> Win Key + 1
#1::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  StringLower, lowercase_string, clipboard
  SendRaw, %lowercase_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return 
First letter uppercase
#2::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  StringLower, lowercase_string, clipboard
  StringLeft, first_letter_of_string, lowercase_string, 1
  StringUpper, first_letter_of_string_uppercase, first_letter_of_string
  StringTrimLeft, rest_of_string, lowercase_string, 1
  SendRaw, %first_letter_of_string_uppercase%%rest_of_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return
First Of Each Word Uppercase
#3::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  ;StringUpper, OutputVar, InputVar [, T] 
  ;StringLower, OutputVar, InputVar [, T] 
  ;[, T] = If the parameter is the letter T, the string will be converted to title case.
  StringLower, first_each_word_uppercase_string, clipboard, T
  SendRaw, %first_each_word_uppercase_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return 
ALL UPPERCASE
#4::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  StringUpper, uppercase_string, clipboard
  SendRaw, %uppercase_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return 
Replace Space by Underscore
#5::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]  
  StringReplace, string_space2underscore, clipboard, %A_SPACE%, _, All
  SendRaw, %string_space2underscore%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return 
Replace Underscore by Space (Remove Underscore)
#6::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]  
  StringReplace, string_underscore2space, clipboard, _, %A_SPACE%, All
  SendRaw, %string_underscore2space%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return
Replace Dot by Space (Remove Underscore)
#7::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]  
  StringReplace, string_underscore2space, clipboard, ., %A_SPACE%, All
  SendRaw, %string_underscore2space%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return
Replace \ by /
#8::  
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]  
  StringReplace, string_underscore2space, clipboard, \, /, All
  SendRaw, %string_underscore2space%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return
Add date at end of a filename
#d::
  FormatTime, TimeString,,_(dd_MMM_yyyy_hhmm)
  Send %TimeString% 
return
Add date at start of filename
;  to use this script you have to define Strg+Alt+Shift+F2 as "cm_CopyNamestoClip" 
;  in TotalCommander's Configuration-Options-Misc-Redefine Hotkeys-Clipboard
#d::  
IfWinActive, ahk_class TTOTAL_CMD			
{
  FormatTime, TimeString,,yyyy_MM_dd__ 
  send ^!+{F2}  							
  send {F6}%TimeString%^v{Enter}								
  return
}

Back to AutoHotkey