2011-02-14 250 views
1

我是VBS的新手。我需要帮助来完成以下步骤;需要将文件从一个文件夹移动到另一个文件夹

1)在某个位置找到最新修改的文​​件夹(带有最新日期时间的文件夹),让C:\ temp。

2)然后发现在子文件夹中的特定文件(extention .TXT)(上述文件夹)

3)复制该文件到另一个位置,让我们假设C:\ temp1目录

4)重命名的文件名设置为当前日期,例如2011-02-14

感谢

回答

2

的VBScript:

BaseDir = "C:\Temp" 
FileToFind = "test.txt" 

Set fs = CreateObject("Scripting.FileSystemObject") 
Set fl = fs.GetFolder(BaseDir) 

For Each sfl In fl.SubFolders 
    If IsNull(fd) Or sfl.DateCreated > fd Then 
     fd = sfl.DateCreated 
     Found = sfl.Path & "\" 
    End If 
Next 

Set f = fs.GetFile(Found & FileToFind) 

f.Copy "C:\Temp1\" & Year(Date) & Month(Date) & Day(Date), True 

可能存在的问题,包括 “ - ” 的文件名,所以我离开了出来。

0

下面是一些伪代码,你会怎么做它在bash在Windows(使用Cygwin)

# change to the directory so we can avoid path issues 
cd /path/to/temp 

# get the most recently modified directory 
myDirectory = "`ls -drt */ | tail -n1`" 

# change to that directory 
cd "$myDirectory" 

# Here you can use cp or mv depending if you want to remove the file from orig 
directory 
cp "specificFile.txt" "/path/to/temp1/`date command with flags`.txt" 
+0

我感谢您的快速回复和帮助,但我很抱歉,这是我的头顶。我特别寻找VB脚本帮助。 – Dexterslab 2011-02-14 22:59:13

相关问题