Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: Find & Copy a file of specific size

HTVi
TV Discussion Newsgroups

Find & Copy a file of specific size
Humdev 5/31/2007 9:23:02 AM
Hi everyone!
I need a script which will search a file of 5MB in a specific folder and
copy it at another location. I know nothing about VBScripts (a little bit
what I know is about BAT files )...
Can any one help me please?

RE: Find & Copy a file of specific size
urkec 5/31/2007 9:09:00 PM
"Humdev" wrote:

[Quoted Text]
> Hi everyone!
> I need a script which will search a file of 5MB in a specific folder and
> copy it at another location. I know nothing about VBScripts (a little bit
> what I know is about BAT files )...
> Can any one help me please?
>


'file size in bytes
fiveMB = 5 * 1024 * 1024

'source and destination folders
source = "C:\folder1\"
dest = "C:\folder2\"

set fso = CreateObject _
("Scripting.FileSystemObject")

'get files in the source folder
set folder = fso.GetFolder (source)
set files = folder.Files

'loop through the files
'if a file is fiveMB or more
'copy it to dest folder

for each file in files
if file.Size >= fiveMB then
WScript.Echo file.Path
'file.Copy dest, true
end if
next

WScript.Echo "Done"


If this is what you want, uncoment the line that coppies files.

--
urkec

Re: Find & Copy a file of specific size
Michael Bednarek <ROT13-zo[ at ]gtz.pbz.nh> 6/1/2007 6:04:58 AM
On Thu, 31 May 2007 02:23:02 -0700, Humdev wrote in
microsoft.public.windows.server.scripting:

[Quoted Text]
>I need a script which will search a file of 5MB in a specific folder and
>copy it at another location. I know nothing about VBScripts (a little bit
>what I know is about BAT files )...

"a file" - just one? "of 5MB" - exactly?

This doesn't strike me as a problem where scripting (as understood in
this ng) is the best solution. Given a proper CLI (4NT), the command is
simply:
COPY /[s5M] dir1\*.* dir2
will copy files >=5MB. 4NT's Size Ranges are documented at
<http://jpsoft.com/help/sizeranges.htm>.

I suspect any other language will need a more elaborate solution.

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
Re: Find & Copy a file of specific size
Humdev 6/1/2007 10:54:01 AM
Thanks a lot urkec & Michael Bednarek!
Let me explain the requirement... We are having a script used to copy the
log generated by ntbackup.exe at a central repository. The old Server being
NT4, was having a single backup.log file for ntbackup.exe (It was also having
facility to define the location where backup log is to be kept) and new
Server is 2K3R2 which creates different log files for each time ntbackup.exe
executes. I am needed to copy the log file with size 5 MB and date stamp of
current date (there are 3 jobs scheduled for the day). Please note that the
script contains the name of file on which the operation of copy & rename is
to be performed.
Thanks.

"Michael Bednarek" wrote:

[Quoted Text]
> On Thu, 31 May 2007 02:23:02 -0700, Humdev wrote in
> microsoft.public.windows.server.scripting:
>
> >I need a script which will search a file of 5MB in a specific folder and
> >copy it at another location. I know nothing about VBScripts (a little bit
> >what I know is about BAT files )...
>
> "a file" - just one? "of 5MB" - exactly?
>
> This doesn't strike me as a problem where scripting (as understood in
> this ng) is the best solution. Given a proper CLI (4NT), the command is
> simply:
> COPY /[s5M] dir1\*.* dir2
> will copy files >=5MB. 4NT's Size Ranges are documented at
> <http://jpsoft.com/help/sizeranges.htm>.
>
> I suspect any other language will need a more elaborate solution.
>
> --
> Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
>
Re: Find & Copy a file of specific size
Michael Bednarek <mbATmbednarek.com[ at ]BLACKHOLESPAM.NET> 6/1/2007 1:05:41 PM
On Fri, 1 Jun 2007 03:54:01 -0700, Humdev wrote in
microsoft.public.windows.server.scripting:

[Quoted Text]
>Thanks a lot urkec & Michael Bednarek!
>Let me explain the requirement... We are having a script used to copy the
>log generated by ntbackup.exe at a central repository. The old Server being
>NT4, was having a single backup.log file for ntbackup.exe (It was also having
>facility to define the location where backup log is to be kept) and new
>Server is 2K3R2 which creates different log files for each time ntbackup.exe
>executes. I am needed to copy the log file with size 5 MB and date stamp of
>current date (there are 3 jobs scheduled for the day). Please note that the
>script contains the name of file on which the operation of copy & rename is
>to be performed.

It always helps if you show the code you have so far.

The following 4NT command will copy all files which have been created
today and are more that 5MB in size:
COPY /[s5M] /[d-0] dir1\*.* dir2

4NT is a commercial program; the same command should also work in 4DOS
which is free and should run in a NT-class OS.

>"Michael Bednarek" wrote:
>
>> On Thu, 31 May 2007 02:23:02 -0700, Humdev wrote in
>> microsoft.public.windows.server.scripting:
>>
>> >I need a script which will search a file of 5MB in a specific folder and
>> >copy it at another location. I know nothing about VBScripts (a little bit
>> >what I know is about BAT files )...
>>
>> "a file" - just one? "of 5MB" - exactly?
>>
>> This doesn't strike me as a problem where scripting (as understood in
>> this ng) is the best solution. Given a proper CLI (4NT), the command is
>> simply:
>> COPY /[s5M] dir1\*.* dir2
>> will copy files >=5MB. 4NT's Size Ranges are documented at
>> <http://jpsoft.com/help/sizeranges.htm>.
>>
>> I suspect any other language will need a more elaborate solution.

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen