Sorry about that! I just threw it together (and edited it about 10 times after posting it!) so I forgot to add the usual AutoHotkey info.
@mouser:
1) can we drag and drop files onto this autohotkey script from explorer to have them renamed?
2) if we compile the script can we do this?
This can easily be added if you compile or say yes to allow dropping on AHK-file when installing AHK.
3) in your line setting the separator, would there be a way to specify a SPACE character as a separator?
Check out the
PatternRenamer script below.
It supports drag and drop or a command line, you can use <space> as a separator, and you can have a multichar separator or several singlechar ones. It also shows a preview of the first new filename before starting the renaming.
Skrommel
;PatternRenamer.ahk
; Rename files
;Skrommel @2005 www.donationcoder.com/Software/Skrommel
#SingleInstance,Force
SetBatchLines,-1
;AutoTrim,Off
separator =-<space> ;Char(s) separating the parts of the input filename, use <space> for space
oneseparator=1 ;0=No 1=Yes Treat the separator as one unit?
outpattern =<4><2>test<2>-<1> ;Pattern of the output filename
inpattern =<1>- <2>- <3>- <4> ;Pattern of the input filename, not in use, just to explain!
Loop,%0%
{
StringReplace,inseparator,separator,<space>,%A_Space%,ReplaceAll
outfile=%outpattern%
shortpath:=%A_Index%
Loop,%shortpath%
longpath=%A_LoopFileLongPath%
SplitPath,longpath,name,dir,ext,name_no_ext,drive
If oneseparator=1
{
StringReplace,name_no_ext,name_no_ext,%inseparator%,``,ReplaceAll
StringSplit,name_,name_no_ext,``
}
Else
StringSplit,name_,name_no_ext,%inseparator%
Loop,%name_0%
%A_Index%:=name_%A_Index%
Loop,%name_0%
{
part:=%A_Index%
StringReplace,outfile,outfile,<%A_Index%>,%part%,ReplaceAll
}
Loop,10
StringReplace,outfile,outfile,<%A_Index%>,,ReplaceAll
If A_Index=1
{
msg=InFile:`t`t%longpath%
msg=%msg%`nOutFile:`t`t%dir%\%outfile%.%ext%
msg=%msg%`nSeparator:`t%separator%
msg=%msg%`nOneSeparator:`t%oneseparator%
msg=%msg%`nInPattern:`t%inpattern%
msg=%msg%`nOutPattern:`t%outpattern%
MsgBox,4,Is this correct?,%msg%
IfMsgBox,No
Break
}
FileMove,%longpath%,%dir%\%outfile%.%ext%,1
}