Q: How would you make a Batch file that moves any file over a certain size to another location?
A: We can do it with VBS, if Operational System is Microsoft (XP/2000/2003 etc.)
May be you know. VBS is simple script language (Same Visual Basic syntax)
1. step is execute dir command in to file,
2.step file reading and file moving\deleting
Same process script read to filename and delete for last 3 days file . Script is below. Have you changed it?
'on error resume next
Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("%comspec% /k dir /b \\server1\C\project\QUALITY\ >> \\server1\C\project\QUALITY\dir.txt")
Wscript.sleep 6000
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
GUN=Weekday(CurrentDate)
hesap=Mid(gun,1,3)
dene =InStr(hesap,1,".")
'Wscript.Echo dene
datex=date-3
tarx=Month(datex)
tary=day(datex)
tarz=year(datex)
tar1=len(Month(datex))
tar2=len(day(datex))
if tar1=1 then tarx="0"&tarx
if tar2=1 then tary="0"&tary
time1=time-0.01
bsaat=mid(time1,1,2)&mid(time1,4,2)&mid(time1,7,2)
silme=tarz&tarx&tary
'Wscript.Echo silme
Set objTextFile = objFSO.OpenTextFile (" \\server1\C\project\dir.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , ",")
i=i+1
'Wscript.Echo silme &" : "&mid(arrServiceList(0),1,8)
sildosya= arrServiceList(0)
dosdos=mid(arrServiceList(0),1,8)
if silme=dosdos then
silsil=" \\server1\C\project\QUALITY\" & sildosya
yoket="%comspec% /c del " & silsil
Set objExecObject = objShell.Exec(yoket)
end if
Loop
objTextFile.close
Set objExecObject = objShell.Exec("%comspec% /c del \\server1\C\project\QUALITY\dir.txt")