Sorry bout the long code snippet, but i didnt have time to sort out the
specifics, so i just dumped the whole script in here.
> Is there a way to list all the files inside a folder where
> there are many
> folders inside a folder and more folders inside each
> individual folders.
Yes there is here is a handler i wrote doing a customized installer back
in -99 so it�s a bit chunky. but it�s what ur looking for i think.
BUT
The installer fell on that at the time there were no way to actually update
the progressbar while a file was being read, so we had to go with
instashield after all since the mainfile was larger than 400 meg =).
<CODE>
property pNewPath
property folderList
property pNotList
on beginSprite me
pNewPath = member("savePath").text
pNotList = []
end
on createFolderTree me --THIS IS PROLLY WHAT U WANT.
baRegister( XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ) --So noone uses
my buddy licence =)
--Creates the path if its not existent
ok = baFolderExists( pNewPath )
if ok = 0 then
baCreateFolder( pNewPath )
end if
-- pseudo progress
sprite(4).loc = point(15,108)
sprite(4).trails = TRUE
-- end pseudo progress
foldList = baFolderList(the moviePath)
folderList = []
repeat with n = 1 to foldList.count
repeat with g = 1 to pNotList.count
notFolder = pNotList[g]
if foldList[n] = notFolder then
next repeat
else
folderList.add(the MoviePath & foldList[n])
end if
end repeat
end repeat
repeat with i = 1 to foldList.count
the itemDelimiter = "\"
aName = foldList[i]
if aName.item.count > 1 then
subList = baFolderList(aName)
else
subList = baFolderList(the moviePath & aName)
end if
if subList.count > 0 then
repeat With x = 1 to sublist.count
newFolder = sublist[x]
folderList.add(the moviePath & aName & "\" & newFolder)
end repeat
else
exit repeat
end if
end repeat
digIn(folderList)
createMainFiles()
end
on digIn orgFolderList --DONT FORGET THIS PART TOO SINCE THIS IS THE
RECURSIVE PART
tempList = []
repeat with x = 1 to orgFolderList.count
aFolder = orgFolderList[x]
put aFolder
checkDepth = baFolderList(aFolder)
if checkDepth <> [] then
repeat With e = 1 to checkDepth.count
aName = checkDepth[e]
tempList.add(orgFolderList[x] & "\" & aName)
folderList.add(orgFolderList[x] & "\" & aName)
digIn(tempList)
end repeat
else
exit repeat
end if
end repeat
startCreatingFiles()
end
on startCreatingFiles me
the itemDelimiter = "\"
destList = []
repeat with m = 1 to folderList.count
aFolder = folderList[m]
delete item 1 to 4 of aFolder
aDest = pNewPath & aFolder
destList.add(aDest)
end repeat
--Creates the folderTree
repeat with f = 1 to destList.count
aNewFolder = destList[f]
-- Updatesa the text over the progressbar used
member("progName").text = aNewFolder
--end update
baCreateFolder(aNewFolder)
-- pseudo progress
sprite(4).locH = sprite(4).locH + 1
updateStage
--End pseudo progress
end repeat
-- copys the files to the right folder
repeat with d = 1 to folderList.count
aFoldPlace = baFileList(folderList[d], "*.*")
repeat with a = 1 to aFoldPlace.count
aFile = aFoldPlace[a]
aOrigin = folderList[d] &"\"& aFile
aTarget = destList[d] &"\"& aFile
-- Updaterar texten
member("progName").text = aFile
--end uppdaterar texten
aCheck = baCopyFile(aOrigin, aTarget , "Always")
-- pseudo progress
sprite(4).locH = sprite(4).locH + 1
updateStage
--End pseudo progress
if not aCheck = 0 then
alert "Summin�s not right chum"
exit repeat
else
next repeat
end if
end repeat
end repeat
end
on createMainFiles me
mainFileList = baFileList(the moviePath, "*.*")
repeat with s = 1 to mainFileList.count
aMainFile = mainFileList[s]
-- Updaterar texten
member("progName").text = aMainFile
--end uppdaterar texten
mainFile = baCopyFile(the moviePath & aMainFile, pNewPath & aMainFile,
"Always")
-- pseudo progress
sprite(4).locH = sprite(4).locH + 1
updateStage
--End pseudo progress
if not mainFile = 0 then
alertH(#copyF)
exit repeat
else
next repeat
end if
end repeat
createStartMenuGroup()
put folderList
end
on createStartMenuGroup me
if the machineType = 256 then
check = baCreatePMGroup( "Vision Park" )
if check = 1 then
-- baCreatePMIcon( pNewPath & "polis2.exe", "Polis 2","",0)
-- baCreatePMIcon( pNewPath & "unInstall.exe", "Avinstallera Polis
2","",0)
--alertH(#skapaR)
else
alertH(#skapaF)
end if
createFolderLog()
end if
end
on unInstallFiles me
put folderList
repeat with i = 1 to folderList.count
aFolder = folderList[i]
the itemDelimiter = "\"
delete item 1 to 4 of aFolder
targFolder = pNewPath & aFolder
someFiles = baFileList(targFolder)
repeat with x = 1 to someFiles.count
if someFiles <> [] then
aFile = someFiles[x]
put "aFolder" & targFolder
put "aFile" & aFile
ok = baDeleteFile(targFolder & aFile)
if ok = 0 then
alertH(#deleteF)
end if
else
next repeat
end if
end repeat
ok = baDeleteFolder(targFolder)
if ok = 0 then
alertH(#deleteF)
end if
end repeat
end
--Throws the right alert message
on alertH whatAlert
case whatAlert of
#deleteF:
alert "kunde inte avinstallera Polis 2"
#skapaF:
alert "Kunde inte skapa" &RETURN& "Vision Park" &RETURN& "i
StartMenyn"
#skapaR:
alert "Skapade" &RETURN& "Vision Park" &RETURN& "i StartMenyn"
#copyF:
alert "filen kopierades inte kolla scriptet"
end case
end
--For debugging the asschewing script b4 actually discarding it
on createFolderLog me
the itemDelimiter = "\"
myDirs = []
repeat with i = 1 to folderList.count
aString = folderList[i]
delete item 1 to 4 of aString
saveString = pNewPath & aString
myDirs.add(saveString)
end repeat
put myDirs
</Code>
This scripts handels everything from creating the specified folders to
creating a startMenu item to uninstalling the files and throwing a list of
the installed files to the message win for debugging.
____________________________________________
Mikael Wir�n
Knowledge Network
Lillhagsv�gen 36
124 71 BANDHAGEN
Tel: +46 (0)8 556 204 50
Mob: +46-(0)709-15 24 30
Mail: [EMAIL PROTECTED]
Web: HTTP://www.knowledgenetwork.se
____________________________________________
>
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]