rename files

real simple one I cant get to work. renaming a file in external dir.

d = @"C:\Users\user\Documents\3dsMax\previews\"
NewDir = @"D:\test\Test\"
--copy file
for f in getFiles (d + "_scene.avi") do
copyFile f (NewDir + getFilenameFile f + getFilenameType f)
--rename file
Files = (NewDir + "_scene.avi")
renamefile ((getFilenameFile files) ("test.avi"))

basically I want to rename _scene.avi to test.avi.

thanks folks

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

You can copy and rename files with one operation:

(
	d = "G:\\scenes\\scenes\\"
	NewDir = "D:\\"
	--copy file
	filesArr = getFiles (d + "*_scene.max")
	format "filesArr: % \n" filesArr
	for f in filesArr do
	(
		--	"copy and rename at the same time"
		copyFile f (NewDir + "test" + getFilenameType f)
 
	)
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.