复制和重命名文件,为每个文件创建一个YYMM前缀 [英] Copy and rename files creating a YYMM prefix for each file

查看:66
本文介绍了复制和重命名文件,为每个文件创建一个YYMM前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个VBScript,它将读取一个文件夹,复制并重命名一组特定的文件.我想在每个重命名的文件前加上"me-YYMM-"文件名.这些文件的名称永远不会更改,但是我希望在运行脚本时使用当前的YYMM来命名重命名的文件.这就是我想要做的.

复制并重命名-c:\ dir1 \ file1到c:\ dir2 \ me-YYMM-file1
复制并重命名-c:\ dir1 \ file2到c:\ dir2 \ me-YYMM-file2

dir1,dir2和文件名将始终是静态的,但是我可能需要在此过程中添加或删除文件.任何帮助,将不胜感激.对我而言,它可以是副本或移动.我必须能够重命名文件.

I am trying to create a VBScript that will read through a folder, copy and rename a specific set of files. I would like to prefix each renamed file with "me-YYMM-" filename. The names of the files will never change, but I want the renamed files to be named with the current YYMM when I run the script. This is what I would like to be able to do.

copy and rename - c:\dir1\file1 to c:\dir2\me-YYMM-file1
copy and rename - c:\dir1\file2 to c:\dir2\me-YYMM-file2

The dir1, dir2 and file names will always be static, but I may need to add or delete files from this process. Any help would be appreciated. For my purposes it could be a copy or a move. I have to be able to rename the files though.

推荐答案

好,首先使用FileSystemObject.CopyFile 复制文件(请参见文档 [ ^ ]
Well, to start off use FileSystemObject.CopyFile to copy the file (see doc[^])

Once you copy the file you need to rename it, right? to do so you FileSystemObject.MoveFile , see doc[^]


这篇关于复制和重命名文件,为每个文件创建一个YYMM前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆