如何将一个或多个扩展名为*.log文件从C盘一个文件夹转移到D盘一个文件夹路径下面?时钟控件时时刻刻判断路径下面有没.log文件,当此文件存在时,即做一个“动作”后转移路径(什么动作就不劳烦大家了),不存在时,什么都不做。
如:C:\TEST\123.LOG
D:\TEST\123.LOG小生试了很多方法,感觉都不是很满意,特来此请教各位大虾!谢谢
如:C:\TEST\123.LOG
D:\TEST\123.LOG小生试了很多方法,感觉都不是很满意,特来此请教各位大虾!谢谢
调试欢乐多
如果用COPY和KILL的话,那就要获取文件名,我想在不获取文件名的情况下,全部转移后缀名为.LOG的文件。
Timer1.Interval = 1000
Timer1.Enabled = True
End SubPrivate Sub Timer1_Timer()
If Dir("c:\test\*.log") <> "" Then
Timer1.Enabled = False
Shell "cmd /c move c:\test\*.log " & "c:\test2"
Timer1.Enabled = True
End If
End Sub
Timer1.Interval = 100
Timer1.Enabled = True
If Dir("c:\test2", vbDirectory) = "" Then MkDir "c:\test2"
End Sub
dim sPath as string
dim dPath as string
sPath="C:\*.log"
dPath="D:\"
Shell "cmd /c move" & sPath & dPath这样为甚么不可以啊?我调试不可以
SHELL既然可以加通配符,那么可以加变量吗?如上所示!有谁知道?
那么有甚么方法可以实现路径也是变量来转移文件
当路径为如:"C:\NEWFILE\"时可以转移文件;
当路径为如:"C:\NEW FILE\"时不可以转移文件;
即我发现SHELL命令后面的文件夹不可以有"空格",只要没有空格,可以实现文件转移,有空格则文件转移失败!问题:
不知道是我的命令什么地方写错了,还是SHELL本来就只有这个功能?
Private Sub Command1_Click()
Shell "cmd /c move " & GetShortName(sPath) & " " & GetShortName(dPath)
End SubPublic Function GetShortName(ByVal sLongFileName As String) As String
Dim lRetVal&, sShortPathName$
sShortPathName = Space(255)
Call GetShortPathName(sLongFileName, sShortPathName, 255)
GetShortName = Mid(sShortPathName, 1, InStr(sShortPathName, Chr(0)) - 1)
End Function
Name "C:\TEST\" & strFile As "D:\TEST\" & strFile
strFile = Dir()
Loop
Shell "cmd /c move """ & sPath & """ """ & dPath & """"