AutoHotkey: Create folders from filenames

From TotalcmdWiki
Revision as of 22:44, 20 October 2005 by Sheepdog (talk | contribs) (backlink)
Jump to navigation Jump to search

From a thread in the english forum:

I have the following set of filenames (example): Code:

0123456ABCDEFGH.jpg
1234567ABCDEFGH.jpg
2345678ABCDEFGH.jpg
3456789BCDEFGHI.jpg
4567890BCDEFGHI.jpg
5678901BCDEFGHI.jgp

I need to create a folder from the last 8 characters from filename (extension not included), then a folder inside that folder with the first 7 characters, and then I need to copy the jpg file inside that last folder.


Mark all files, press Ctrl+Alt+C.

Icfu

~^!c::
IfWinActive, ahk_class TTOTAL_CMD
{
  ControlGetFocus, Control, ahk_class TTOTAL_CMD
  If (Control="TMyListBox1" or Control="TMyListBox2")
  {
    SendMessage 1075, 2029, , , ahk_class TTOTAL_CMD
    SetWorkingDir, %clipboard%
    SendMessage 1075, 2017, , , ahk_class TTOTAL_CMD
    Loop, Parse, Clipboard, `n, `r
      {
        StringLeft, Left, A_LoopField, 7
        StringMid, Right, A_LoopField, 8, 8
        FileCreateDir, %Right%\%Left%
        FileCopy, %A_LoopField%, %Right%\%Left%
      }
   } 
}
Return



Back to AutoHotkey