/*
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
Original issue reported on code.google.com by
kijoshua...@gmail.com
on 2 Aug 2008 at 3:42