vbs拷贝文件夹obj中和文件夹jpg下文件名相同的文件到model目录下代码

window上边想批量操作文件还是vbs方便

以后不常用window了 下边记录一个vbs拷贝文件的代码 方便以后使用

set fso = createobject("scripting.filesystemobject")
set shell = createobject("wscript.shell")

set dir = fso.getfolder(".\jpg\")
set dir1 = fso.getfolder(".\obj\")
dim dir3 : dir3 = ".\model\"

for each fj in dir1.files
	objname = fj.name
	objname = cstr(objname)
	if len(objname) > 4 and right(objname, 4) = ".obj" then
		objname = left(objname, len(objname)-4)
		for each fi in dir.files
			jpgname = fi.name
			jpgname = cstr(jpgname)
			if len(jpgname) > 4 and right(jpgname, 4) = ".jpg" then
				jpgname = left(jpgname, len(jpgname)-4)
				if jpgname = objname then
					'msgBox jpgname+"==="+objname
					fso.MoveFile fj.path, dir3+fj.name
					fso.moveFile fi.path, dir3+fi.name
				end if
			end if
		next
	end if
next
msgbox "ok"


 

你可能感兴趣的:(shell,each)