[Closed] Adopt max file to folder name ??
i have series of folder containing single max file in each folder, when i open the work.max file, it should adopt the folder name and the 3dsmax file to be converted as FolderA.max
how can this be done… is there any way,
, i am new to scripting, ,
how my series of files are
FolderA 3dsmax file named work.max
FolderB 3dsmax file named work.max
FolderC 3dsmax file named work.max
If i have well understood this is your hierarchy :
C:\RootFolder
......FolderA\
............Work.max
......FolderB\
............Work.max
......FolderC\
............Work.max
and you want to convert that into :
C:\RootFolder
......FolderA\
............FolderA.max
......FolderB\
............FolderB.max
......FolderC\
............FolderC.max
To do that, you could use this script :
(
-- Put your root folder here
RootFolder = "C:\\RootFolder\\"
-- This will get all the directories contained in the root folder and put them into an array :
folders = getDirectories (RootFolder+"*")
-- Now Loop into the array
for f in folders do (
-- Get the FolderName, without the total path.
foldername = substring f (RootFolder.count+1) (f.count - (RootFolder.count+1))
-- Get the files contained in the folder
files = getFiles (f+"\\*.max")
-- Check if there is only one max file in that folder.
if files.count==1 then (
-- Create the new FileName (With the path included)
newFileName = f+foldername+".max"
-- Rename the file
renameFile files[1] newFileName
)
)
)
Use it at your own risks, be careful because it renames files !
You must replace the RootFolder and have the same hierarchy as in my example.
Also there must be only one maxfile in the folder.
many thanks floatin_
very nice coding,
i didnt tested though,
but very happy in getting a reply with coding…
Super and excellent coding, , works very good…
its as exactly as i want
thank you.
this script i tried like getting files from a single folder,
its opening a pair of files only, its not going for third file, why,
i feel i have to make something like making an increment on the loadmax files array selection of files in that folder…
if files.count>1 then (
files = getFiles (maxfilepath+”*.max”)
loadmaxfile files[1]
CurrentFileIndex = finditem files (maxfilepath+maxfilename)
LoadMaxFile files[CurrentFileIndex+1]
)