@filesize result for directory?

May 27, 2008
10
0
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?
 
May 20, 2008
3,515
4
Elkridge, MD, USA
---- Original Message ----
From: hwilkins
To: ESFabian@zenge.org
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,514
18
Solon, OH, USA
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
>
> Samintz@ra.rockwell.com
>
> 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?
>
>
>
>
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly @FILESIZE and NTFS File Stream Support 1
vefatica @FILESIZE[] ... allocated ... unexpected results Support 0
rps @FILESIZE[....,a] allocated size not matching Dir results Support 8
rps Fixed @filesize[...,a] space allocated values incorrect Support 2
vefatica @FILESIZE ... allocated space Support 7
M @Files and @FileSize failures... Support 2
M @FileSize - How is this possible? Support 10
M @Files, @FileSize returning nothing... Support 7
M A (minor) limitation of @FileSize... Support 6
JohnQSmith WAD Incorrect results from @FILESIZE Support 9
dcantor Build 56 @FILESIZE problem Support 2
X How to set %_INIREAD result to variable Support 5
D Catching the result of an evaluated script expression Support 0
rps Fixed V17 @name adding quote (") to result Support 5
G TCMD does not get same result as cmd.exe Support 22
M Weird @Index function result... Support 7
L FFIND no result display Support 10
vefatica PSHELL changes directory Support 3
fishman@panix.com HELP!! I just updated to Version 28 and as usual I cannot make extended directory search work. Support 2
D How to use multi-line DO to loop through first level directory names Support 5
D ParentDirectory does not update directory history Support 6
samintz CDD to non-existent directory hangs Support 2
gworley rd (Remove Directory) gives interesting error: Support 2
D Directory History Window with wildcard search Support 3
D How to? Skip removing directory (RMDIR) without error message Support 2
gentzel Directory stack empty when running TCEXIT? Support 9
vefatica Disable extended directory searches (completely)? Support 8
M WAD "Pictures" directory is empty in TCC but not in CMD or Explorer Support 4
G Local Directory Corruption Support 11
Jay Sage Directory Alias Access to FTP Servers Support 2
Joe Caverly DIRectory Colorization in v25 Help File Support 0
K copy changing destination current directory Support 1
thorntonpg option /u not working The directory name is invalid Support 5
J built in file explorer - how do i go back "up" the directory? Support 2
vefatica Extended directory searches? Support 6
Joe Caverly Using a Directory Alias with @iniwrite fails Support 14
A Installer /extract: extracts into current directory if target not exists Support 12
Charles Dye Ctrl-Shift-Up doesn't update directory history Support 1
G Extended directory search not working Support 4
CWBillow Editing in the root directory of windows 10 Support 6
D Directory stack empty Support 1
J directory or folder to start in Support 2
M How to unlock a directory Support 1
Alpengreis Fixed TCMD FileExplorer Start-Directory problem Support 4
R V19 - At startup, TCC save directory in the directory history list Support 2
C Touch command — I Need to touch matching files in another directory. Support 5
nickles Move takecommand.18.0.key location to installation directory Support 4
fishman@panix.com Extended Directory Searches are not working for me in CDD Support 9
vefatica TCMD's current directory? Support 4
J How to set working directory Support 10

Similar threads