AutoHotkey: Create folders from filenames

From TotalcmdWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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