PDA

View Full Version : Batch Export Problem


Jonbojangles
02-14-2006, 05:29 PM
I am able to return all the directories, but none of the files inside of those directories.

Any help is much appreciated. Thank you


button file_button "Testing" width:180
on file_button pressed do
(
global FindFiles
fn FindFiles dir fileMask =
(
_max_src = ("Z:\character")
--output= ("Z:\image-dump")
global dir = _max_src

-- dir has the rootDir to operate on
-- fileMask has the file wildcard pattern


local rootDir = dir
rootDir = TrimRight rootDir
rootDir = TrimRight rootDir "\\/" -- Remove any trailing slash
-------------------------------------------------
dirArray = GetDirectories (rootDir + "\\*")
for d in dirArray do
(
join dirArray (GetDirectories (d + "*"))
)
--------------------------------------------------
files = getFiles (rootDir + \\*.max (file://\*.max))
for f in files do
(
join files (getFiles (f + "*.max"))
)
--------------------------------------------------
--------------------------------------------------
)
--print(FindFiles)
--print(dirArray)
--print(files)
)

Aearon
02-14-2006, 08:09 PM
here's a function i use to get files recursively, maybe this can help you

fn getFilesRecursive root pattern inclRoot:true filter:".svn" =
(
local dir_array = GetDirectories (root+"\\*")

if filter != undefined then dir_array = for d in dir_array where findString d filter == undefined collect d

for d in dir_array do
(
local newDirs = GetDirectories (d+"*")

if filter != undefined then newDirs = for d in newDirs where findString d filter == undefined collect d

join dir_array newDirs
)

if inclRoot then
my_files = (getFiles (root + pattern))
else
my_files = #()

for f in dir_array do join my_files (getFiles (f + pattern))

my_files
),

Aearon
02-14-2006, 08:11 PM
files = getFiles (rootDir + \\*.max (file://%5c*.max/))
for f in files do
(
join files (getFiles (f + "*.max"))
)


i think your error is here, shouldn't this loop run over the dirs instead of the files?

files = getFiles (rootDir + \\*.max (file://%5c*.max/))
for d in dirArray do
(
join files (getFiles (d + "*.max"))
)

Jonbojangles
02-15-2006, 01:03 AM
Perfect!

Thank you very much.

--Jon

CGTalk Moderation
02-15-2006, 01:03 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.