@filesize result for directory?

May 27, 2008
10
0
#1
I have an alias that processes files versus directories differently that was originally written for 4NT v4 ... just seeing the light of day again.

Back then, @FILESIZE returned -1 for directories, but it appears that today it returns 0 for them. No sweat -- things change.

What is the most efficient way to tell if a string represents a file versus a directory?

I am looking at possibly using @FOLDERS, as in:

if %@folders["%i"\..] GT 0 [it's a folder, do folder stuff]
if %@folders["%i"\..] EQ 0 [it's a file, do file stuff]

Is there a better way?
 
#2
---- Original Message ----
From: hwilkins
To: [email protected]
Sent: Tuesday, 2011. February 8. 05:00
Subject: [Support-t-2589] @filesize result for directory?

| I have an alias that processes files versus directories differently
| that was originally written for 4NT v4 ... just seeing the light of
| day again.
|
| Back then, @FILESIZE returned -1 for directories, but it appears that
| today it returns 0 for them. No sweat -- things change.
|
| What is the most efficient way to tell if a string represents a file
| versus a directory?
|
| I am looking at possibly using @FOLDERS, as in:
|
| if %@folders["%i"\..] GT 0 [it's a folder, do folder stuff]
| if %@folders["%i"\..] EQ 0 [it's a file, do file stuff]
|
| Is there a better way?

Use the @ATTRIB function:

switch %@attrib[filespec,D]
case 0
:: process as a file
case 1
:: process as a directory
endswitch

BTW, FOLDER is a more generic term than DIRECTORY - all directories are folders, but not all folders are directories (for example some are a collection of directories).
--
HTH, Steve
 

samintz

Scott Mintz
May 20, 2008
1,295
11
Solon, OH, USA
#3
How do you get the names in the first place?
Is it your desire to process only files or to process everything
in a tree and take different action based on whether it's a file or folder?

You can use the ISDIR and/or ISFILE
conditionals within an IFF or IF statement.

help conditionalexpressions

-Scott

hwilkins <> wrote on 02/08/2011
05:00:31 AM:


> hwilkins <>
> 02/08/2011 05:00 AM
>
> Please respond to
>
>
> To
>
> [email protected]
>
> cc
>
> Subject
>
> [Support-t-2589] @filesize result for directory?
>
> I have an alias that processes files versus directories differently

> that was originally written for 4NT v4 ... just seeing the light of
day again.

>
> Back then, @FILESIZE returned -1 for directories, but it appears
> that today it returns 0 for them. No sweat -- things change.
>
> What is the most efficient way to tell if a string represents a file
> versus a directory?
>
> I am looking at possibly using @FOLDERS, as in:
>
> if %@folders["%i"\..] GT 0 [it's a folder, do folder stuff]
> if %@folders["%i"\..] EQ 0 [it's a file, do file stuff]
>
> Is there a better way?
>
>
>
>