ScriptSpot

Forum topic · Scripts Wanted

zip files by object names in scene

By tosyk · 2012-12-30

Description

I have a bunch objects in the scene and a folder with an files with a same names as objects, so i need to collect in array object names and tell maxscript to zip files with the same name.

please help me

p.s.: i know about setting object names in array by

namesArray = for s in selection collect s.name
Comments (3)

which utility you used for zipping?

Anubis · 2012-12-31

with WinRAR for example...

CD C:\Program Files (x86)\WinRAR\
WinRAR a arhive_name "C:\My Folder\*.jpg"

...above batch file will made arhive "arhive_name.rar" from all JPG files in "C:\My Folder".

And if i've got your question right, and if WinRAR is fine for your needs, then...

namesArray = for s in selection collect s.name
theFolder = "C:\\Tmp\\" -- replace with your source folder
theExt = ".jpg" -- replace with your file type

-- default install location of WinRAR:
WinRAR = "C:\Program Files (x86)\WinRAR\WinRAR"
-- command A mean ADD (create new archive)
cmd = "\"" + WinRAR + "\" A "

for n in namesArray where \
doesFileExist (theFolder + n + theExt) do
HiddenDOSCommand (cmd + n + " " + n + theExt) startpath:theFolder

barigazy · 2012-12-31

Very nice example.
Can you show also example of archiving (similar to Maz()function) but using WINRAR or 7Zip. These two software has a far better compression then maxzip.
Thanks in advance.
Cheers and Happy New Year!

Happy New Year!

Anubis · 2013-01-01

I have not 7Zip, as for WinRAR (I showed in above example) it's syntax is very closer to Maz() function:

WINRAR A archiveFileName fileName_or_pattern