Thanks for your imput jaco0646 - very useful
Its been several months since i wrote this script, but think maybe what i meant by "for use with FileMove" was not that FileMove required long filenames, but that i use long filenames in the variables used by the FileMove statement (just sth to remind me
why i was converting 8.3 into long). This reason being mainly (as you said) for display in message box, but also as i felt it was easier to use overall than staying with 8.3 (ie convert all into long, then that's it .. no need for any more conversions (eg 8.3 --> display filename)). But i will erase this text in next version
I have implemented "run only once" option of SetTimer (guess i didn't see that in the help!)
I have replaced "Sleep" with "WinWait"
Now leaves path as 8.3
Recreated code to calculate/extract path & filename (from pathname)
Fixed a bug concerning pathnames containing spaces
Concerning the reg entries, i already created a .reg file, but it's only for XP (the instructions allow people with other OS's to alter it to fit). Maybe later i'll create an installer script to detect Windows type, & add the keys to registry
I initially considered putting in SendTo menu, but decided to put in root of context menu, as i use the extension quite a lot (so saves time by being in root)
Code:
#NoEnv
SetTitleMatchMode, 3 ;Exact
SetTitleMatchMode, Slow
SetKeyDelay, 0
AutoTrim, Off
#NoTrayIcon
; Re-join passed parameter-parts into single parameter (if path has space/s)
pathname_from =
space_to_add =
Loop, %0%
{
part_to_add := %A_Index%
pathname_from = %pathname_from%%space_to_add%%part_to_add%
space_to_add = %A_Space%
}
; Split pathname into path + filename.ext
;
StringGetPos, pos_of_last_slash, pathname_from, \, r1 ;Find last "\"
;
filename_ext_len := StrLen(pathname_from) - pos_of_last_slash - 1
StringRight, filename_ext_from, pathname_from, filename_ext_len
;
path_len := pos_of_last_slash
StringLeft, path_from, pathname_from, path_len
; Launch separate thread (which will do stuff while CURRENT (main) thread is "stuck" in InputBox)
SetTimer, Highlight_Extension, -1 ;-1 = execute once only + go there now (& start waiting for InputBox to exist)
; Input box
InputBox, altered_name_ext, Change Filename/Extension, Enter new filename.ext,, 250, 125,,,,,%filename_ext_from%
If ErrorLevel = 1 ;Press Esc key on keyboard
Exit
; Change the filename/extension
path_to := path_from
pathname_to = %path_to%\%altered_name_ext%
FileMove, %pathname_from%, %pathname_to%
ExitApp
;-----------------------------------------------
Highlight_Extension:
WinWait, Change Filename/Extension,,2 ;Gives InputBox 2 secs to be created (eg system on a "go-slow")
; Ensure Input-Box exists
If ErrorLevel = 1
ExitApp ;No InputBox opened (for some unknown reason), so exit script
Else
{ ;InputBox opened
IfWinNotActive, Change Filename/Extension
{
WinActivate, Change Filename/Extension
WinWaitActive, Change Filename/Extension
}
}
Send {End}{Shift Down}{Left}{Left}{Left}{Shift Up} ;Highlights just the extension (.abc)
Return
;-----------------------------------------------