Technical support and scripting issues
Moderators: JRL, Dorian (MJT support)
-
paperboy666
- Newbie
- Posts: 1
- Joined: Sat Apr 02, 2005 2:49 pm
Post
by paperboy666 » Sat Apr 02, 2005 2:55 pm
Hello
I need some help/a point in the proper direction. I need to check the size of a directory and if it is equal to or greater than 4 gig move that directory to another drive.
Is there an example of this or can someone give me a hand. I am not new to programming but I am to VBScript. Some to the things you can and can't do have me a little confused.
Thanks
Greg

-
Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
-
Contact:
Post
by Bob Hansen » Sat Apr 02, 2005 4:44 pm
No need for VB, use DOS commands:
Basic structure shown here, no time to do in Macro Scheduler right now. Syntax is not good.......
---------------------------
RP_WAIT=1
Run Program> dir > dirsize1.txt
Run Program> find "file(s)" dirsize1.txt > dirsize2.txt
//The total bytes will now be on line 2 of dirsize2.txt.
Now you can parse dirsize2.txt to strip out the size and compare it to maximum desired, and move, copy, delete, whatever you want to do....
ReadLn>dirsize2.txt,2,NeedToParse
....
....
IF>Bytes>4G,Move
--------------------------------
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
-
Captive
- Macro Veteran
- Posts: 213
- Joined: Sun Oct 20, 2002 8:37 pm
- Location: Colorado, USA
Post
by Captive » Sat Apr 02, 2005 8:45 pm
If you are interested in using vbscript, which reduces the chance of failure, and stops you depending on external timing / windows / programs, here is an example (posted by Marcus a while back) how to obtain file and size count.
If counts sub-dirs, but doesn't reset itself to 0 after it's ran... that can be changed if required.
VBSTART
Set objFSO = CreateObject ("Scripting.FileSystemObject")
dim intFil
dim bytes
Sub CountFiles1(Folder)
Set colFiles= Folder.files
For each objFile in colFiles
intFil=intFil+1
bytes=bytes+objFile.size
Next
For Each Subfolder in Folder.SubFolders
Set objfolder= objFSO.GetFolder(Subfolder.Path)
CountFiles Subfolder
Next
End Sub
Sub CountFiles(FolderSpec)
CountFiles1(objFSO.GetFolder(FolderSpec))
End Sub
VBEND
Rem> This runs the "CountFiles" routine, which puts it's results in to the VB "intFil" and "bytes" variables.
VBRun>CountFiles,C:\Path\To\Folder
Rem>This copies the values of "intFil" to %totfiles%, and "bytes" to the %totbytes% variables.
VBEval>intFil,totfiles
VBEval>bytes,totbytes
Rem> Announce the files + bytes.
MessageModal> Files: %totfiles% Bytes: %totbytes%