DonationCoder.com Software > Post New Requests Here
IDEA - a simple way to batch rearrange blocks of text within filenames
skrommel:
:tellme: 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
}
jovejupiter:
Hi again Skrommel,
I downloaded AutoHotkey which looks extremely useful - The only problem is that your script only rearranges the name of the first file in the folder and doesn't repeat the operation for the other files.
The documentation on the website looks pretty extensive - Does anybody have the whole set of documentation as a single pdf (or similar) rather than as a set of web pages?
Cheers
Tony
jovejupiter:
Hi again Skrommel,
I converted your pattern renamer script to an exe on my desktop and it seems to work fine for drag and drop.
Cheers
Tony
jovejupiter:
Hi again,
The program is converting multiple files but seems to miss a few files and leaves them unchanged.
Cheers
Tony
skrommel:
:tellme: Still got problems? Care to elaborate?
Skrommel
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version