Create folders from filenames

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
CoMiKe
Senior Member
Senior Member
Posts: 285
Joined: 2003-05-05, 17:45 UTC
Location: Salamanca, Spain

Create folders from filenames

Post by *CoMiKe »

Hi!

I've accepted a challenge :wink: to create folders from filenames. And before I start to write some code, I want to know if TC can do this task.

I have the following set of filenames (example):

Code: Select all

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.

If the multirename tool could create directories, this would be very easy:

Code: Select all

[N8-]\[N1-7]\[N].[E]
But this does not work (MRT doesn't accept backslashes to create folders). Can anyone suggest a workaround?

Thanks in advance.
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

AutoHotkey-Script is no problem, tell me if you are interested.

Icfu
This account is for sale
User avatar
CoMiKe
Senior Member
Senior Member
Posts: 285
Joined: 2003-05-05, 17:45 UTC
Location: Salamanca, Spain

Post by *CoMiKe »

Thanks, icfu!

But I've made a C program for this task, and it seems to work. :wink:
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Nevertheless, I did one myself, you never know when you need it. ;)

Code: Select all

~^!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
Mark all files, press Ctrl+Alt+C.

Icfu
Last edited by icfu on 2005-10-11, 23:14 UTC, edited 1 time in total.
This account is for sale
User avatar
CoMiKe
Senior Member
Senior Member
Posts: 285
Joined: 2003-05-05, 17:45 UTC
Location: Salamanca, Spain

Post by *CoMiKe »

Great, it seems it's easier to do it with autohotkey. :)
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Edited it a little bit to make it even easier. ;)

Icfu
This account is for sale
Raymond
Senior Member
Senior Member
Posts: 454
Joined: 2003-02-08, 15:43 UTC

Post by *Raymond »

Here is another way:
1, Compress each file with "Create separate archives, one per selected file/dir"
2, Uncompress them with "Unpack each archive to a separate subdir (name of the archive)"
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Have you posted in the wrong thread? If no, please read again.
Your way has nothing to do with the problem at all.

Icfu
This account is for sale
Raymond
Senior Member
Senior Member
Posts: 454
Joined: 2003-02-08, 15:43 UTC

Post by *Raymond »

icfu wrote:Have you posted in the wrong thread? If no, please read again.
Your way has nothing to do with the problem at all.
Icfu
Did you say to me? I don't think so.
Of coz I omited some easy steps such as trimming last 8 or 7 characters from filename, etc. My way can quickly create multi folders from filenames, right? I'm sure your script works perfectly for the task, but if the task is only needed once occasionally instead of everyday work, my way is an option, I guess.
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Afterwards you have to create additional parent folders for each folder because your solution creates one additional hierarchy level only, you have to move each folder to its parent folder, you have to copy each filename string, rename the subfolder with the first seven characters, rename the parent folder with the last eight characters and maybe merge identically named folders.
I'm sure your script works perfectly for the task, but if the task is only needed once occasionally instead of everyday work, my way is an option, I guess.
This depends on the amount of files I'd say. Starting from five files already this is an option for Sisyphus only if you ask me, but not for people who like to get the job done in a reasonable amount of time with no errors. ;)

Icfu
This account is for sale
Post Reply