PC Review


Reply
Thread Tools Rate Thread

Cannot copy file in spite of size file fits space available?

 
 
Joachim Hofmann
Guest
Posts: n/a
 
      16th Oct 2008
Hello,

I have a batch file which does some copy jobs nightly.

I wish to copy a file only if there is enough space, otherwise I wish to delete
some other file(s).

I get the size of the file to be copied by the for...%~zI - clause.
DIR gives me the free disk space into another variable.

Now I compare these values (and redirect the output into a logfile).
========================================================================

Result of the *first* copy job:
disk free: 33013485568
file size: 18418023936

Result message of copy: "Network is not available any more"

Result of the *following* copy job:

disk free: 24847392768
file size: 18418023936

Result message of copy: "Not enough space available"


The *following* job (3037577216, 77614592) however succeeded as I expected.

========================================================================

Whats wrong, any hints?

Thank You

Joachim

[Windows 2000 Server]

 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      16th Oct 2008

"Joachim Hofmann" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I have a batch file which does some copy jobs nightly.
>
> I wish to copy a file only if there is enough space, otherwise I wish to
> delete
> some other file(s).
>
> I get the size of the file to be copied by the for...%~zI - clause.
> DIR gives me the free disk space into another variable.
>
> Now I compare these values (and redirect the output into a logfile).
> ========================================================================
>
> Result of the *first* copy job:
> disk free: 33013485568
> file size: 18418023936
>
> Result message of copy: "Network is not available any more"
>
> Result of the *following* copy job:
>
> disk free: 24847392768
> file size: 18418023936
>
> Result message of copy: "Not enough space available"
>
>
> The *following* job (30 37 577 216, 77 614 592) however succeeded as I
> expected.
>
> ========================================================================
>
> Whats wrong, any hints?
>
> Thank You
>
> Joachim


Let's have a look at your batch file.
Also: Have you tried copying your files manually? If yes, by what method?


 
Reply With Quote
 
Joachim Hofmann
Guest
Posts: n/a
 
      20th Oct 2008
Pegasus (MVP) wrote:

> Have you tried copying your files manually? If yes, by what method?


Not so easy to reproduce by day.
This special case normally only happens on a Saturday, when the Admin was not
present to delete old files manually, so that on this day there is less disk
space.
On Mo-Fr, when there is more space, it works.

Example:
disk free: 66381103104
file size: 30682228224
-> copy ok

So I thought it could be a difference between actual disk space and calculated
disk space.

> Let's have a look at your batch file.


1 FOR /F "usebackq" %%F in (`DIR %BasePath% /AD /B`) DO (
2 FOR /F "usebackq tokens=2 delims= " %%D IN (`DATE /t`) DO (
4 FOR %%B IN (%BasePath%%%F\%Filemask%) DO (
5 ECHO Backup: %%~nxB to %%~nB_%%D%%~xB... >> logfile.log
6 ECHO Comparing free disc space and file size ...
7 FOR /F "usebackq tokens=3 delims=, " %%I IN (`DIR /-c ^| findstr "Bytes.frei"`) DO (
8 IF %%~zB GTR %%I (
9 ECHO No space -%%I- for file -%%~zB- , deleting existing file before copying new one
>> logfile.log

10 DEL %ZielMandantPfad%%%F\%%i >> logfile.log 2>&1
11 ) ELSE (
12 ECHO Space enough -%%I- for file -%%~zB- >> logfile.log
13 ))
14 COPY %%B %ZielMandantPfad%%%F\%%~nB_%%D%%~xB >> BefehlsausgabenVoll.log 2>&1
15 ...


In 4 I get the file name into %%B
In 7 I put the "Bytes free" output into %%I
In 8 I compare these two values to decide what to do: deleting existing file or
not

Hmm.. as I write this, I notice that in 10 I am using %%i, I think it should be
%%B; %%i is a size variable.

I will change that and watch what the job does.

Joachim

 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      20th Oct 2008

"Joachim Hofmann" <(E-Mail Removed)> wrote in message
news:O$(E-Mail Removed)...
> Pegasus (MVP) wrote:
>
> > Have you tried copying your files manually? If yes, by what method?

>
> Not so easy to reproduce by day.
> This special case normally only happens on a Saturday, when the Admin was
> not
> present to delete old files manually, so that on this day there is less
> disk
> space.
> On Mo-Fr, when there is more space, it works.
>
> Example:
> disk free: 66381103104
> file size: 30682228224
> -> copy ok
>
> So I thought it could be a difference between actual disk space and
> calculated
> disk space.
>
> > Let's have a look at your batch file.

>
> 1 FOR /F "usebackq" %%F in (`DIR %BasePath% /AD /B`) DO (
> 2 FOR /F "usebackq tokens=2 delims= " %%D IN (`DATE /t`) DO (
> 4 FOR %%B IN (%BasePath%%%F\%Filemask%) DO (
> 5 ECHO Backup: %%~nxB to %%~nB_%%D%%~xB... >> logfile.log
> 6 ECHO Comparing free disc space and file size ...
> 7 FOR /F "usebackq tokens=3 delims=, " %%I IN (`DIR /-c ^| findstr
> "Bytes.frei"`) DO (
> 8 IF %%~zB GTR %%I (
> 9 ECHO No space -%%I- for file -%%~zB- , deleting existing
> file before copying new one
> >> logfile.log

> 10 DEL %ZielMandantPfad%%%F\%%i >> logfile.log 2>&1
> 11 ) ELSE (
> 12 ECHO Space enough -%%I- for file -%%~zB- >> logfile.log
> 13 ))
> 14 COPY %%B %ZielMandantPfad%%%F\%%~nB_%%D%%~xB >>
> BefehlsausgabenVoll.log 2>&1
> 15 ...
>
>
> In 4 I get the file name into %%B
> In 7 I put the "Bytes free" output into %%I
> In 8 I compare these two values to decide what to do: deleting existing
> file or
> not
>
> Hmm.. as I write this, I notice that in 10 I am using %%i, I think it
> should be
> %%B; %%i is a size variable.
>
> I will change that and watch what the job does.
>
> Joachim
>


No, %%i is not a size variable, it is nothing because it is in lower case.
Your code does not appear to set it in any way.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
validating if a file is a true valid xml file that fits a certain schema Andy B Microsoft VB .NET 5 2nd Jul 2008 03:01 AM
Copy a file with Windows Explorer reserves the file size in advanc =?Utf-8?B?Q2FsaW4gSWFydQ==?= Windows XP General 2 9th Mar 2007 08:13 AM
file size and space used =?Utf-8?B?c21vcmc=?= Microsoft Windows 2000 File System 3 16th Nov 2004 03:31 AM
File size vs disk space Barir Malik Windows XP General 7 17th Oct 2003 04:25 PM
File size vs disk space Barir Malik Windows XP Basics 7 17th Oct 2003 04:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:03 AM.