KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Question about file extentions

 
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic
View previous topic :: View next topic  
Author Message
Bertje
KiXforms Regular
KiXforms Regular


Joined: 25 Aug 2003
Posts: 38
Location: Sneek, The Netherlands

PostPosted: Fri Sep 19, 2003 7:41 am    Post subject: Question about file extentions Reply with quote

Hey all,

And yet a question from me Cool
I'm working on a "cmd" script
just for fun. But I want to add color's
to file extions. So if the extention is .Kix
then the color is red etc etc
I have did but I don't work
Code:

$FileName = Dir("E:\Kix\cmd")
While $FileName <> "" AND @ERROR = 0
  If $filename = "*.kix"
  Color b
  EndIf
  ? $FileName
  $FileName = Dir() ; retrieve next file
Loop

I know it is the example from the help but I'm first testing.
I really hope that you can help me.

_________________
Greetz,
Bertje
Back to top
View user's profile Send private message AIM Address MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Sep 19, 2003 8:52 am    Post subject: Reply with quote

Umm, you can't use wildcards in there Shocked

try:

Code:
if right($filename,3) = 'kix'

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Fri Sep 19, 2003 11:36 am    Post subject: Reply with quote

The following example is more adaptable code, DIRLIST() is a UDF from http://www.kixtart.org
Code:

$files = dirlist('e:\kix\cmd\')
for each $file in $files
  if instr($file,'.')
    ;might need improvements to take care of dots in directory names, there's a UDF for this
    $ext=split($file,'.')
    $ext=$ext[ubound($ext)]
  else
    $ext=''
  endif
  select
  case $ext='kix'
    $color='red'
  case $ext='udf'
    $color='yellow'
  case 1
    $color='green'
  endselect
  Color $color
  ? $FileName
next

_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Bertje
KiXforms Regular
KiXforms Regular


Joined: 25 Aug 2003
Posts: 38
Location: Sneek, The Netherlands

PostPosted: Wed Sep 24, 2003 7:19 am    Post subject: Reply with quote

Jochen wrote:
Umm, you can't use wildcards in there Shocked

try:

Code:
if right($filename,3) = 'kix'


Yeah kay thanks you that works ^^
Man you guy's are smart Razz

_________________
Greetz,
Bertje
Back to top
View user's profile Send private message AIM Address MSN Messenger
Bertje
KiXforms Regular
KiXforms Regular


Joined: 25 Aug 2003
Posts: 38
Location: Sneek, The Netherlands

PostPosted: Wed Sep 24, 2003 7:20 am    Post subject: Reply with quote

Sealeopard wrote:
The following example is more adaptable code, DIRLIST() is a UDF from http://www.kixtart.org
Code:

$files = dirlist('e:\kix\cmd\')
for each $file in $files
  if instr($file,'.')
    ;might need improvements to take care of dots in directory names, there's a UDF for this
    $ext=split($file,'.')
    $ext=$ext[ubound($ext)]
  else
    $ext=''
  endif
  select
  case $ext='kix'
    $color='red'
  case $ext='udf'
    $color='yellow'
  case 1
    $color='green'
  endselect
  Color $color
  ? $FileName
next


Tryed that but to complicate for me Embarassed

_________________
Greetz,
Bertje
Back to top
View user's profile Send private message AIM Address MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Wed Sep 24, 2003 12:03 pm    Post subject: Reply with quote

Please elaborate what exactly is "too complicated"?

You will need to have some kind of evaluation logic in order to
a) differentiate between folders and files
b) identify a file extension in a file
c) change only the desired fileextensions

Changing the last three characters in a file/foldername is not sufficient as you might have a folder c:\temp\test.kix or a file c:\temp\akix with no extension.

_________________
Jens

'There are two kinds of vessels, submarines and targets.'


Last edited by Sealeopard on Thu Sep 25, 2003 11:42 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Bertje
KiXforms Regular
KiXforms Regular


Joined: 25 Aug 2003
Posts: 38
Location: Sneek, The Netherlands

PostPosted: Thu Sep 25, 2003 10:58 am    Post subject: Reply with quote

Sealeopard wrote:
Please elaborate what exactly is "too complicated"?

You will need to have some kind of evaluation login in order to
a) differentiate between folders and files
b) identify a file extension in a file
c) change only the desired fileextensions

Changing the last three characters in a file/foldername is not sufficient as you might have a folder c:\temp\test.kix or a file c:\temp\akix with no extension.


Aha I understand, I'm still fighting with the script ^^

_________________
Greetz,
Bertje
Back to top
View user's profile Send private message AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group