monolithpl / stexbar

Windows Explorer extensions (or: what Microsoft forgot to implement in the Windows Explorer)
7 stars 4 forks source link

"shorten" AutoHotKey script submission #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
/*
    This was from a while ago!  I made this script to cleanup folders after
unzipping many
    things at once.  I always hated how some would zip their folders while
others would zip
    their items.  I just ended up extracting to a folder every time and then
checking each
    folder to see if it was redundant or not.  Like 

    finding
    ...\mystuff\mystuff\<files>
    and fixing it to be
    ...\mystuff\<files>

    All this does is spills any selected folder that contains precisely one
folder and no files.

*/

loop %0%
{
    folder := %A_Index%

    files := 0
    loop, %folder%\*.*
        files++

    folders := 0
    loop, %folder%\*.*, 2
    {
        folders++
        real_folder = %A_LoopFileFullPath%
        real_fname = %A_LoopFileName%
    }

    if (files = 0) and (folders = 1)
    {
        StringGetPos,break,folder,\,R1
        StringLeft,dest,folder,%break%
        StringGetPos,break,dest,\,R1
        StringRight,dest_fname,dest,%break%
        ;MsgBox, changing %real_folder% to %dest%\%real_fname%
        FileMoveDir, %real_folder%, %dest%\%real_fname%, 2
        if ErrorLevel
            MsgBox, error changing %real_folder% to %dest%\%real_fname%
        else if  dest_fname <> %real_fname%
            FileRemoveDir, %folder%
    }
    if (files = 0) and (folders = 0)
        FileRemoveDir, %folder%
}

QUIT:
return

Original issue reported on code.google.com by kijoshua...@gmail.com on 2 Aug 2008 at 3:42

GoogleCodeExporter commented 9 years ago

Original comment by tortoisesvn on 2 Aug 2008 at 3:49

GoogleCodeExporter commented 9 years ago
Compiled version (doesn't require AutoHotKey to run)

Original comment by kijoshua...@gmail.com on 2 Aug 2008 at 4:36

Attachments: