Exclude From Array

D

doubleJ

----- batch begins -------
[1]@echo off
[2]setlocal enabledelayedexpansion
[3]for /r c:\106x %%i in (.) do set yfn=%%i&set yfn=!yfn:~3,-2!&set
yfn=!yfn:\=_!& RAR a "c:\destdir\!yfn!.rar" "%%i\*.*"
[4]goto :eof
------ batch ends --------

Hello...
I have this batch in operation (it looks at all the subdirectories and
creates a .rar file for each), and it works well. The only problem is
that it will take approximately 5 days to complete.
Hehehe...
Is there a way that I can explicitely exclude directories from the
array?

For instance...
c:\106x - 5mb
c:\106x\dir1 - 3mb
c:\106x\dir2 - 50mb
c:\106x\dir2 - 10gb
c:\106x\dir3 - 1mb

Could the script be written in such a way as to automatically exclude
any directory containing more than 1gb or to manually set exclusions?
I could take those directories out of the tree, but I'd rather not.
JJ
 
B

billious

doubleJ said:
----- batch begins -------
[1]@echo off
[2]setlocal enabledelayedexpansion
[3]for /r c:\106x %%i in (.) do set yfn=%%i&set yfn=!yfn:~3,-2!&set
yfn=!yfn:\=_!& RAR a "c:\destdir\!yfn!.rar" "%%i\*.*"
[4]goto :eof
------ batch ends --------

Hello...
I have this batch in operation (it looks at all the subdirectories and
creates a .rar file for each), and it works well. The only problem is
that it will take approximately 5 days to complete.
Hehehe...
Is there a way that I can explicitely exclude directories from the
array?

For instance...
c:\106x - 5mb
c:\106x\dir1 - 3mb
c:\106x\dir2 - 50mb
c:\106x\dir2 - 10gb
c:\106x\dir3 - 1mb

Could the script be written in such a way as to automatically exclude
any directory containing more than 1gb or to manually set exclusions?
I could take those directories out of the tree, but I'd rather not.
JJ


----- batch begins -------
[1]@echo off
[2]setlocal enabledelayedexpansion
[3]for /r c:\106x %%i in (.) do (
[4] set yfn=%%i
[5] set yrs=0
[6] set yds=0
[7] for /f "skip=3tokens=3" %%j in ( ' dir /a-d/-c "%%i" 2^>nul' ) do set
yds=000000000000000!yrs!&set yrs=%%j
[8] set yds=!yds:~-12!
[9] if !yds! neq 000000000000 if !yds! leq 000000001000 set
yfn=!yfn:~3,-2!&set yfn=!yfn:\=_!&ECHO RAR a "c:\destdir\!yfn!.rar"
"%%i\*.*"
[10])
[11]goto :eof
------ batch ends --------

Lines start [number] - any lines not starting [number] have been wrapped
and should be rejoined. The [number] that starts the line should be removed

The label :eof is defined in NT+ to be end-of-file but MUST be expressed
as :eof

The spaces surrounding the single-quotes are for emphasis only. The SPACES
are not required but the single-quotes ARE required.

C:\106x... is my test directory.

[8] : the "12" sets the length of the strings on [9]
[9] : the all-zeroes excludes empty directories. the second number is the
max size of dir
The ECHO keyword needs to be removed to activate the RAR action

That takes care of the max-dir-size problem.

To manually set exclusions, you could try a sequence of

[8a]if "%%i"=="c:\106x\leave\me\out\." set yds=X

for each exclude-directory. Note the terminal "\." and not tested with
non-alphameric names....
 
D

doubleJ

Is there a Not Equal symbol? I've seen NEQ, but I wasn't sure if \= or
something would be better, since you use == instead of EQU.
JJ
 
F

foxidrive

Is there a Not Equal symbol? I've seen NEQ, but I wasn't sure if \= or
something would be better, since you use == instead of EQU.
JJ
[8a]if "%%i"=="c:\106x\leave\me\out\." set yds=X


if not "%%i"=="c:\106x\leave\me\out\." set yds=X
 
D

doubleJ

[01]@echo off
[02]setlocal enabledelayedexpansion
[03]for /r \\Audioserver\Audio1\Download %%i in (.) do (
[04] set filename=%%i
[05] set exclusion=0
[06] if %%i == \\Audioserver\Audio1\Download\Games\. set exclusion=1
[07] if !exclusion! == 0 (
[08] set filename=!filename:~14,-2!
[09] set filename=!filename:\=_!
[10] RAR a \\audioserver\audio1\backup\test\!filename!.rar %%i\*.*
[11] )
[12])
[13]goto :eof

This is what I have thusfar, but it will create a file for
\\Audioserver\Audio1\Download\Games\Quake. I'm guessing that there is
a way to recurse that if statement.
If there is a better way to do this, I would be happy to change it.
This just seemed the most logical to me.
JJ
 
B

billious

doubleJ said:
[01]@echo off
[02]setlocal enabledelayedexpansion
[03]for /r \\Audioserver\Audio1\Download %%i in (.) do (
[04] set filename=%%i
[05] set exclusion=0
[06] if %%i == \\Audioserver\Audio1\Download\Games\. set exclusion=1
[07] if !exclusion! == 0 (
[08] set filename=!filename:~14,-2!
[09] set filename=!filename:\=_!
[10] RAR a \\audioserver\audio1\backup\test\!filename!.rar %%i\*.*
[11] )
[12])
[13]goto :eof

This is what I have thusfar, but it will create a file for
\\Audioserver\Audio1\Download\Games\Quake. I'm guessing that there is
a way to recurse that if statement.
If there is a better way to do this, I would be happy to change it.
This just seemed the most logical to me.
JJ

Ah - a matter of clearly specifying quite WHAT you want to do.

If you wish to exclude _A_ directory or a set of directories, then
[06] if %%i == \\Audioserver\Audio1\Download\Games\. set exclusion=1

[06a] if %%i == \\Audioserver\Audio1\Download\someother\. set exclusion=1

[06b] if %%i == \\Audioserver\Audio1\Download\yetanother\. set exclusion=1
....

(note that %%i and !filename! are identical in this example)

But if you want to exclude a directory _AND ALL OF ITS SUBDIRECTORIES_ then

[04a] set pathname=%filename:~0,-1%
....
[06] if %%i==\\Audioserver\Audio1\Download\Games\. set exclusion=1

[06a] if !pathname!==\\Audioserver\Audio1\Download\someother\ set
exclusion=1

[06b] if !pathname!==\\Audioserver\Audio1\Download\yetanother\ set
exclusion=1
[06c] if !filename!==\\Audioserver\Audio1\Download\yetanother\. set
exclusion=0

where [06] will exclude ...\Games but NOT its subdirectories
[06a] will exclude ...\someother AND its subdirectories
[06b] WOULD exclude ...\yetanother AND its subdirectories
were it not for
[06c] which turns the exclusion OFF again for ...\yetanother - but ONLY for
....\yetanother - not its subdirectories.

Note that the terminal "." is missing from [06a],[06b]; [04a] establishes
PATHNAME from all-but-the-last-char of FILENAME

* FILENAME is misleading. It isn't a filename.

note also that

IF /i

will make the comparison case-insensitive

and the syntax

IF NOT

inverts the == - BUT this is inapplicable in this application (except for
contrived examples) because

(pseudocode, not batchcode)
if NOT directory=firstdirectory set exclude=yes
if NOT directory=seconddirectory set exclude=yes

will ALWAYS set exclude to yes - and in your original query, you stated that
you wished to exclude a list of directories.
 
D

doubleJ

Thank you...
Where do you find out about ~3's and -2's and all that? I've looked at
some different scripting sites, but I haven't seen explanations. I get
that ~3 means match 3 characters (or something) and I think -2 means
delete those 3 characters. I'm sure you can specify from the beginning
or from the end, etc...
A link for some of that would be sufficient. I don't expect you to
teach me. You've been extremely helpful.
JJ
 
B

billious

doubleJ said:
Thank you...
Where do you find out about ~3's and -2's and all that? I've looked at
some different scripting sites, but I haven't seen explanations. I get
that ~3 means match 3 characters (or something) and I think -2 means
delete those 3 characters. I'm sure you can specify from the beginning
or from the end, etc...
A link for some of that would be sufficient. I don't expect you to
teach me. You've been extremely helpful.
JJ

From the prompt, try

SET /? | more

and the documentation (such as it is) will appear as if by magic.

In essence,
set varname1=%varname2:~m,n%

will set varname1 to the n characters of varname2 starting at position m -
where the first character is m=0
the ",n" can be omitted, whereupon the assignment is of that part of
varname2 starting at position m.

When m or n are negative, both mean "character count from the end" as the
start and end positions.

For more info, try the newsgroup alt.msdos.batch.nt
many examples, discussions and cold-blooded dissections of various
techniques and work-arounds.
 
D

doubleJ

[01]@echo off
[02]setlocal enabledelayedexpansion
[03]for /r \\Audioserver\Audio2\BatchedMasters %%i in (.) do (
[04] set filename=%%i
[05] set pathname=!filename:~0,40!
[06] set exclusion=0
[07] if !pathname!==\\Audioserver\Audio2\BatchedMasters\Trac set
exclusion=1
[08] if !pathname!==\\Audioserver\Audio2\BatchedMasters\Jobs set
exclusion=1
[09] if !exclusion!==0 (
[10] set filename=!filename:~14,-2!
[11] set filename=!filename:\=_!
[12] RAR a \\audioserver\audio1\backup\audio2\!filename!.rar %%i\*.*
[13] )
[14])
[15]goto :eof

Notice a difference in pathname...
~0,-1 did not exclude directories, but ~0,42 did. It needed to exclude
things that started with !filename!.

In this example, I have to make sure that each exlusion line is 40
characters long. Is there an easy way to make that dynamic (Trac
should actually be Tracks, etc...)? I could set a variable for each
excluded directory, but that's lame.

One thing that I noticed, I cannot do...
if !filename:~0,42!==
It says that 42! is unexpected.
JJ
 
B

billious

billious said:
But if you want to exclude a directory _AND ALL OF ITS SUBDIRECTORIES_
then
[04a] set pathname=%filename:~0,-1%
doubleJ said:
[01]@echo off
[02]setlocal enabledelayedexpansion
[03]for /r \\Audioserver\Audio2\BatchedMasters %%i in (.) do (
[04] set filename=%%i
[05] set pathname=!filename:~0,40!
[06] set exclusion=0
[07] if !pathname!==\\Audioserver\Audio2\BatchedMasters\Trac set
exclusion=1
[08] if !pathname!==\\Audioserver\Audio2\BatchedMasters\Jobs set
exclusion=1
[09] if !exclusion!==0 (
[10] set filename=!filename:~14,-2!
[11] set filename=!filename:\=_!
[12] RAR a \\audioserver\audio1\backup\audio2\!filename!.rar %%i\*.*
[13] )
[14])
[15]goto :eof

Notice a difference in pathname...
~0,-1 did not exclude directories, but ~0,42 did. It needed to exclude
things that started with !filename!.

In this example, I have to make sure that each exlusion line is 40
characters long. Is there an easy way to make that dynamic (Trac
should actually be Tracks, etc...)? I could set a variable for each
excluded directory, but that's lame.

One thing that I noticed, I cannot do...
if !filename:~0,42!==
It says that 42! is unexpected.
JJ

OK - a few things here.

First is a matter of protocol. End-posting (tagging comments to the END of a
message, not the top) is standard for usenet. It aids others to follow a
discussion without scrolling UP to the next point and DOWN to read that
point. Some people will automatically ignore threads that don't follow the
protocol - which reduces and delays replies.

Next:

the set varname=%varname2:~0,-1% was intended to trim the trailing "." from
the directoryname provided by FOR /R. This means that if you did not
terminate the directory name-to-match with a "\" then the IF would not match
!pathname! to directory-name-without-terminal-\

Since you haven't posted the failed code, only your modifications, it's not
possible to determine whether this was actually the case.

Nevertheless, the code I posted was bogus. It wouldn't work properly. Below
is a replacement.

Given a directory structure, requiring to
* exclude ...excludeme, but not its subdirectories
* exclude ...excludetree AND its subdirectories

C:\106x\xdtest\excludeme
C:\106x\xdtest\excludetree
C:\106x\xdtest\excludetree2
C:\106x\xdtest\includeme
C:\106x\xdtest\excludeme\andnotmeeither
C:\106x\xdtest\excludeme\butnotme
C:\106x\xdtest\excludetree\dumpme
C:\106x\xdtest\excludetree\dumpmetoo
C:\106x\xdtest\includeme\andme
C:\106x\xdtest\includeme\andmetoo



----- batch begins -------
[1]@echo off
[2]setlocal enabledelayedexpansion
[3]for /r c:\106x\xdtest %%i in (.) do (
[4]REM Note REM works in a do ( ... ) construct - :: does not
[5]REM Grab the directoryname to ydn
[6]set ydn=%%i
[7]
[8]REM initialise yxd - eXclude-Directory flag
[9]set yxd=N
[10]
[11]REM exclude c:\106x\excludeme ONLY - not its subdirectories
[12]if /i %%i==c:\106x\xdtest\excludeme\. set yxd=Y
[13]
[14]REM exclude c:\106x\xdtest\excludeTREE AND its subdirectories
[15]echo %%i|find /i "c:\106x\xdtest\excludeTREE\" >nul& if not errorlevel 1
set yxd=Y
[16]
[17]if !yxd!==N echo PROCESS %%i
[18]if not !yxd!==N echo BYPASS %%i
[19])
------ batch ends --------

Lines start [number] - any lines not starting [number] have been wrapped
and should be rejoined. The [number] that starts the line should be removed

which yields the following output:

PROCESS c:\106x\xdtest\.
BYPASS c:\106x\xdtest\excludeme\.
PROCESS c:\106x\xdtest\excludeme\andnotmeeither\.
PROCESS c:\106x\xdtest\excludeme\butnotme\.
BYPASS c:\106x\xdtest\excludetree\.
BYPASS c:\106x\xdtest\excludetree\dumpme\.
BYPASS c:\106x\xdtest\excludetree\dumpmetoo\.
PROCESS c:\106x\xdtest\excludetree2\.
PROCESS c:\106x\xdtest\includeme\.
PROCESS c:\106x\xdtest\includeme\andme\.
PROCESS c:\106x\xdtest\includeme\andmetoo\.

Noting that this procedure uses NEITHER filename NOR pathname - even if yDN
is established in [6]. You will probably need to use it to process the "\"
to "_" for your application - but you know how to do that...

* Note the terminal "\" on the directoryname on [15] This makes sure that
c:\106x\xdtest\excludetree is bypassed - but that
c:\106x\xdtest\excludetree2 is processed
* Note the terminal "\." on [12] which selects precisely THAT directory and
no other.

* Comments
The official comment-indicator is REM. Many users use the double-colon
structure as it's easier to type and less clumsy. HOWEVER, it fails in a
parenthesised-do.

* On style:
I use variable names that are three letters, starting with "y". It may be
cryptic, but it allows the contents of variables I have established by
simply issuing the command

SET Y

(which may be followed by a PAUSE command if convenient)
- no Microsoft-established variables begin "y" so I can easily isolate MY
variables.

* On IF !varname:~m,n!==...

does not work.

True. It's a quirk.

IF "!varname:~m,n!"=="..."

works though
 
D

doubleJ

First is a matter of protocol. End-posting (tagging comments to the END of a
message, not the top) is standard for usenet. It aids others to follow a
discussion without scrolling UP to the next point and DOWN to read that
point. Some people will automatically ignore threads that don't follow the
protocol - which reduces and delays replies.

I'm not quite sure what you're referring to, here. I'm going to split
this up in post/reply format. Hopefully, that is correct.
Since you haven't posted the failed code, only your modifications, it's not
possible to determine whether this was actually the case.

[01]@echo off
[02]setlocal enabledelayedexpansion
[03]for /r \\Audioserver\Audio2\BatchedMasters %%i in (.) do (
[04] set yfn=%%i
[05] set ypn=%yfn:~0,-1%
[06] set yxd=0
[07] if !ypn!==\\Audioserver\Audio2\BatchedMasters\Tracks\ set yxd=1
[08] if !yxd!==0 (
[09] set yfn=!yfn:~14,-2!
[10] set yfn=!yfn:\=_!
[11] RAR a \\audioserver\audio1\backup\test\!yfn!.rar %%i\*.*
[12] )
[13])
[14]goto :eof

Note that there is no error, it simply makes the files that weren't
intended. Also note the change in variable names. I see your naming
convention and it's virtues.

Creating archive
\\audioserver\audio1\backup\test\Audio2_BatchedMasters_Tracks.rar
Adding
\\Audioserver\Audio2\BatchedMasters\Tracks\.\Tag-WordSender.pk OK
Adding
\\Audioserver\Audio2\BatchedMasters\Tracks\.\Tag-WordSender.wav OK
Done
Creating archive
\\audioserver\audio1\backup\test\Audio2_BatchedMasters_Tracks_0100-Singles.rar
WARNING: No files
Creating archive
\\audioserver\audio1\backup\test\Audio2_BatchedMasters_Tracks_0100-Singles_0100-05.rar
Adding
\\Audioserver\Audio2\BatchedMasters\Tracks\0100-Singles\0100-05\.\Track001.wav
0%
User break
Terminate batch job (Y/N)? y

[05] set ypn=!yfn:~0,-1!

Note that there is no error, it bypasses BatchedMasters\Tracks and
processes BatchedMasters\Tracks\0100-Singles

Creating archive
\\audioserver\audio1\backup\test\Audio2_BatchedMasters_Tracks_0100-Singles.rar
WARNING: No files
Creating archive
\\audioserver\audio1\backup\test\Audio2_BatchedMasters_Tracks_0100-Singles_0100-05.rar
Adding
\\Audioserver\Audio2\BatchedMasters\Tracks\0100-Singles\0100-05\.\Track001.wav
1%
User break
Terminate batch job (Y/N)? y
* Note the terminal "\" on the directoryname on [15] This makes sure that
c:\106x\xdtest\excludetree is bypassed - but that
c:\106x\xdtest\excludetree2 is processed

I see that the ~0,40 way will cause excludetree2 to be bypassed, as
well. Thankfully, I have it set up in such a fashion where that isn't
an issue. I'll keep that code handy, though, should it arise.
* Comments
The official comment-indicator is REM. Many users use the double-colon
structure as it's easier to type and less clumsy. HOWEVER, it fails in a
parenthesised-do.

I hadn't seen ::, but thanks for mentioning it. I probably wouldn't
have figured it out, if I had seen it.
IF "!varname:~m,n!"=="..."
works though

I couldn't get IF %%i:~m,n to work in any variant (!!, %%, etc...). Is
that just not available?
JJ
 
B

billious

doubleJ said:
First is a matter of protocol. End-posting (tagging comments to the END
of a
message, not the top) is standard for usenet. It aids others to follow a
discussion without scrolling UP to the next point and DOWN to read that
point. Some people will automatically ignore threads that don't follow
the
protocol - which reduces and delays replies.

Since you haven't posted the failed code, only your modifications, it's
not
possible to determine whether this was actually the case.

* Note the terminal "\" on the directoryname on [15] This makes sure that
c:\106x\xdtest\excludetree is bypassed - but that
c:\106x\xdtest\excludetree2 is processed

* Comments
The official comment-indicator is REM. Many users use the double-colon
structure as it's easier to type and less clumsy. HOWEVER, it fails in a
parenthesised-do.

IF "!varname:~m,n!"=="..."
works though


I'm not quite sure what you're referring to, here. I'm going to split
this up in post/reply format. Hopefully, that is correct.


[01]@echo off
[02]setlocal enabledelayedexpansion
[03]for /r \\Audioserver\Audio2\BatchedMasters %%i in (.) do (
[04] set yfn=%%i
[05] set ypn=%yfn:~0,-1%
[06] set yxd=0
[07] if !ypn!==\\Audioserver\Audio2\BatchedMasters\Tracks\ set yxd=1
[08] if !yxd!==0 (
[09] set yfn=!yfn:~14,-2!
[10] set yfn=!yfn:\=_!
[11] RAR a \\audioserver\audio1\backup\test\!yfn!.rar %%i\*.*
[12] )
[13])
[14]goto :eof

Note that there is no error, it simply makes the files that weren't
intended. Also note the change in variable names. I see your naming
convention and it's virtues.

Creating archive
\\audioserver\audio1\backup\test\Audio2_BatchedMasters_Tracks.rar
Adding \\Audioserver\Audio2\BatchedMasters\Tracks\.\Tag-WordSender.pk OK
Adding \\Audioserver\Audio2\BatchedMasters\Tracks\.\Tag-WordSender.wav OK
Done
Creating archive
\\audioserver\audio1\backup\test\Audio2_BatchedMasters_Tracks_0100-Singles.rar
WARNING: No files
Creating archive
\\audioserver\audio1\backup\test\Audio2_BatchedMasters_Tracks_0100-Singles_0100-05.rar
Adding
\\Audioserver\Audio2\BatchedMasters\Tracks\0100-Singles\0100-05\.\Track001.wav
0%
User break
Terminate batch job (Y/N)? y

[05] set ypn=!yfn:~0,-1!

Note that there is no error, it bypasses BatchedMasters\Tracks and
processes BatchedMasters\Tracks\0100-Singles

Creating archive
\\audioserver\audio1\backup\test\Audio2_BatchedMasters_Tracks_0100-Singles.rar
WARNING: No files
Creating archive \\audioserver\audio1\backup\test\Audio2_BatchedMasters_Tracks_0100-Singles_0100-05.rar
Adding
\\Audioserver\Audio2\BatchedMasters\Tracks\0100-Singles\0100-05\.\Track001.wav
1%
User break
Terminate batch job (Y/N)? y


I see that the ~0,40 way will cause excludetree2 to be bypassed, as
well. Thankfully, I have it set up in such a fashion where that isn't
an issue. I'll keep that code handy, though, should it arise.


I hadn't seen ::, but thanks for mentioning it. I probably wouldn't
have figured it out, if I had seen it.

I couldn't get IF %%i:~m,n to work in any variant (!!, %%, etc...). Is
that just not available?
JJ


Top-posting : Like emails now are. You're familiar with the content, and
no-one else is going to join the conversation.

End-posting : All comments are added at the END. This allows others to join
in and to easily follow the thread.

Interspersed : Interspersed comments are often hard-to-find.


Batch job:

The problem is in line [05]

[05] set ypn=%yfn:~0,-1%

which should be

[05] set ypn=!yfn:~0,-1!

"%varname%" is the value of the variable when the interpreter encounters the
FOR.
"!varname!" is the value of the variable as modified (the IMMEDIATE or
DYNAMIC value)

Minor problem : line [07]

IF /i .....

will make the comparison case-insensitive. Probably not an actual problem,
but case-differences can be hard to pick.


Line [09]

try

[09] for /f "tokens=1*delims=\" %%q in ("!yfn:~0,-2!") do set yfn=%%r

This takes the current value of yFN (except for the last 2 characters) and
"tokenises" it - breaks it up using "\" as a delimiter. It ignores leading
delimiters, puts the first token ("Audioserver") into "%%q" and the
remainder of the line into "%%r"

- that way, you're not counting characters.

see

FOR /?

from the prompt for the TOKENS= and DELIMS= options.



:: is a common 'unofficial' remark 'keyword' - it's really establishing a
label - which is why it doesn't work in a do (...) construct - labels not
allowed!

I'd suggest you look into newsgroup alt.msdos.batch.nt - which has about
five times the volume of traffic as this group has. Heaps of examples and
techniques on show...




if !varname:~n,m!==..... will not work.

Fundamentally, IF looks for items separated by well, separators - some of
which are optional. The most common separator is SPACE so

IF /i %fred%==something

works as advertised.

BUT comma is also a separator.
IF,/i,%fred%==something

will also work.

With

if !varname:~n,m!==.....

IF interprets that as

IF,!varname:~n,m!

It's aware of the keywords "/I" and "not" and "!varname:~n" is neither of
those, so it then expects "==" and reports a syntax violation if it doesn't
find "=="

The way to get around this problem is by enclosing the string in
double-quotes. IF then regards anything between the quotes as a string - and
that allows the special meaning as separators of spaces and commas to be
bypassed.

hence

if "!varname:~n,m!"=="target string" .....

will work - and the double-quotes are REQUIRED.
 
D

doubleJ

Ok...
On a slightly different slant...
How could I exclude particular files within a directory?
In this case, I have a directory where filenames are date-time
(060101-1000.wav). The directory is about 266GB and a rar won't come
close to finishing overnight.
I'd like to be able to say something like...

if "!filename:~0,6!" >= "060101" && if "!filename:~0,6!" <= "060331" do
(
rar bleh bleh bleh
)

I tried making use of the scripts that have been set before, but they
never array files, only directories.
JJ
 
B

billious

doubleJ said:
Ok...
On a slightly different slant...
How could I exclude particular files within a directory?
In this case, I have a directory where filenames are date-time
(060101-1000.wav). The directory is about 266GB and a rar won't come
close to finishing overnight.
I'd like to be able to say something like...

if "!filename:~0,6!" >= "060101" && if "!filename:~0,6!" <= "060331" do
(
rar bleh bleh bleh
)

I tried making use of the scripts that have been set before, but they
never array files, only directories.
JJ

If you have the filenames in a file (jjxd4.txt) - no reason why they
shouldn't be generated by a ' dir /b ....' or some other method : (I just
used a file for testing)

==== jjxd4.txt ========
051231somename1.txt
060101somename2.txt
060102somename3.txt
060330somename4.txt
060331somename5.txt
060401somename6.txt
==== ========


----- batch begins -------
[1]@echo off
[2]setlocal enabledelayedexpansion
[3]for /f %%i in (jjxd4.txt) do (
[4] set yfn=%%i
[5] if "!yfn:~0,6!" GEQ "060101" if "!yfn:~0,6!" LEQ "060331" echo RAR !yfn!
[6] )
[7]echo ===========
[8]for /f %%i in (jjxd4.txt) do (
[9] set yfn=%%i
[10] set yfd=!yfn:~0,6!
[11] if !yfd! GEQ 060101 if !yfd! LEQ 060331 echo RAR !yfn!
[12] )
[13]goto :eof
------ batch ends --------

Lines start [number] - any lines not starting [number] have been wrapped
and should be rejoined. The [number] that starts the line should be removed

The ECHO keyword needs to be removed to activate the rename/delete
It is there as a safety measure to show what the process WOULD do until
you have verified that it will do what you require

The label :eof is defined in NT+ to be end-of-file but MUST be expressed
as :eof

%varname% will be evaluated as the value of VARNAME at the time that
the line is PARSED. The ENABLEDELAYEDEXPANSION option to SETLOCAL causes
!varname! tobe evaluated as the CURRENT value of VARNAME - that is, as
modified by the operation of the FOR

Two different methods.
 
D

doubleJ

billious said:
[3]for /f %%i in (jjxd4.txt) do (

Hehehe...
Well, that was easy enough. It would be better, in the long run to
have it dynamic, but for now that works. I guess I could put...
dir \\bleh\bleh\bleh > jjxd4.txt
within the script, or could I make use of stin?
JJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top