there you go
Code:
SetWorkingDir %A_ScriptDir%
dir_to_check = %A_ScriptDir%
move_to_dir = %A_desktop%\test
filecreatedir, %move_to_dir%
Loop, %dir_to_check%\*, 2
{
hasother=no
hasrar=no
Loop, %A_LoopFileName%\*, 1, 1
{
if (A_LoopFileName!="Thumbs.db" && InStr(A_LoopFileAttrib, "D")=0)
{
SplitPath, A_LoopFileName,,, fileext
if (fileext!="rar" && fileext!="zip")
{
hasother=yes
break
}
if (fileext="rar")
{
rardir:=A_LoopFileDir
rardir2:=rardir
hasrar=yes
}
}
}
if (hasother="no" && hasrar="no")
{
FileRemoveDir, %A_LoopFileName%, 1
}
if (hasrar="yes")
{
StringGetPos, sym_pos, rardir, \, R
if (errorlevel=0)
{
rardir:=SubStr(rardir, sym_pos+2)
}
newdir=%move_to_dir%\%rardir%
ifexist, %newdir%
{
loop
{
ifnotexist, %newdir% (%A_Index%)
{
newdir=%newdir% (%A_Index%)
break
}
}
}
Filemovedir, %rardir2%, %newdir%
}
}