(Msg. 1) Posted: Thu Oct 16, 2008 6:56 pm
Post subject: Cannot copy file in spite of size file fits space available? Archived from groups: microsoft>public>win2000>file_system (more info?)
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.
(Msg. 2) Posted: Thu Oct 16, 2008 7:43 pm
Post subject: Re: Cannot copy file in spite of size file fits space available? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
"Joachim Hofmann" <speicher.DeleteThis@freenet.de> wrote in message
news:ejj8xA7LJHA.3496@TK2MSFTNGP04.phx.gbl...
> 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?
(Msg. 3) Posted: Mon Oct 20, 2008 6:29 pm
Post subject: Re: Cannot copy file in spite of size file fits space available? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
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.
(Msg. 4) Posted: Mon Oct 20, 2008 7:31 pm
Post subject: Re: Cannot copy file in spite of size file fits space available? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
"Joachim Hofmann" <speicher DeleteThis @freenet.de> wrote in message
news:O$wJNEtMJHA.5692@TK2MSFTNGP04.phx.gbl...
> 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.
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum