2011-02-14 241 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

相關問題