ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

IDEA - a simple way to batch rearrange blocks of text within filenames

<< < (2/4) > >>

skrommel:
 :) Here's a quick script I think works...

Just edit the three first lines.

Edited 2005.27: Changed the script to work properly with multiple files.

Skrommel



--- ---path       =C:\Temp             ;Path to the files to rename
inseparator=-                   ;Char(s) separating the parts of the filename
outfile    =<4><2>test<2>-<1>   ;Pattern of the output filename
;infile    =<1>-<2>-<3>-<4>     ;Pattern of the input filename, not used

Loop,%path%\*.*,,1
{
  outname=%outfile%
  Splitpath,A_LoopFileFullPath,name,dir,ext,name_no_ext,drive
  StringSplit,name_,name_no_ext,%inseparator%
  Loop,%name_0%
    %A_Index%:=name_%A_Index%
  Loop,%name_0%
  {
    part:=%A_Index%
    StringReplace,outname,outname,<%A_Index%>,%part%,ReplaceAll
  }
  FileMove,%A_LoopFileFullPath%,%dir%\%outname%.%ext%
}

jovejupiter:
Hi Skrommel,

Thanks for the script.
This is probably going to seem an odd question for a forum like this, but how do I run it?
I've been using computers since the late 70s but somehow I've never had time to get into coding. (apart from HTML and assorted in-programme macros)

As an aside, can anybody recommend a good introduction to scripting, which takes you from the real basics up to a reasonably competent level? Things like this make me think that I really should put some time aside to learn more about the subject.

Cheers

Tony

mouser:
it's not an add question -
i think skrommel is so used to using "AutoHotkey" that he forgets that most of the world has never heard of it.

all of skrommel's utilities are written in a very cool free scripting language system called AutoHotkey:
http://www.autohotkey.com/

it's definitely worth installing since you'll probably be seeing more scripts from skrommel you like :)

most of the time skrommel adds tools to his page but sometimes if its short like this one he just pastes it in a reply.

so you would copy and paste his code and save it as a file with a .ahk extension, and then after you install AutoHotkey you can run it (or compile it into an exe using autohotkey tool).


while i'm here i have a question for skrommel:

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?
3) in your line setting the separator, would there be a way to specify a SPACE character as a separator?

jovejupiter:
Thanks Mouser,

I'll have a look at AutoHotkey

Cheers

Tony

brotherS:
Hi jovejupiter, welcome to the forum! Make sure to read https://www.donationcoder.com/forum/index.php?topic=1167.0 too :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version