Если вы хотите использовать VBScript, вы можете использовать этот сценарий в качестве основы:
' use a default source path or get one from the command line parameters
dim sourcepath: sourcepath = "some\default\path"
if WScript.Arguments.Named.Exists("source") then
sourcepath = WScript.Arguments.Named("source")
end if
' use a default destination path or get one from the command line
dim destinationpath: destinationpath = "some\default\path"
if WScript.Arguments.Named.Exists("destination") then
destinationpath = WScript.Arguments.Named("destination")
end if
' use a default file size limit or get one from the command line
' we accept in kbytes so we convert this to bytes
dim sizelimit: sizelimit = 6000 * 1024 ' default 6000 kbytes
if WScript.Arguments.Named.Exists("sizelimit") then
sizelimit = WScript.Arguments.Named("sizelimit")
end if
' use a Scripting.FileSystemObject to get the file objects of each file
' in the source directory. The file object has a Size property, which
' has the file size in bytes
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
dim sourcefolder: set sourcefolder = fso.GetFolder(sourcepath)
if not fso.FolderExists(destinationpath) then
' we'll throw an error if the path is not found but you could instead
' create the directory automatically
err.raise 1,,destinationpath & " not found"
end if
' loop through each file in the directory, compare size property against
' the limit and copy as appropriate
dim file, count: count = 0
for each file in sourcefolder.Files
if file.size > sizelimit then
file.Move destinationpath
count = count + 1
end if
next
WScript.Echo("complete: " & count & " file(s) moved")
Вы можете запустить это (назовите его move-files.vbs
) из командного файла следующим образом:
cscript move-files.vbs /source:"C:\Documents and Settings\Username\Desktop" /destination:"F:\backup" /sizelimit:1000