List files

By dataprofile on Sep 12, 2007

Lists files in a specified directory in a new @window.

Usage:

/dirlist_ (directory) list (txtfiles,inifiles,(or enter a type of file using the format: .dat [as an example].))

alias dirlist_ { 
  var %x = $1
  if ($2 iswm list) { 
    if (!$window(@files)) { window -lk @files }
    if ($3 iswm txtfiles) { 
      var %c = $findfile(%x,*.txt,0,aline -p @files $1-) 
      return %c 
    } 
    if ($3 iswm inifiles) { 
      var %c = $findfile(%x,*.ini,0,aline -p @files $1-) 
      return %c 
    }
    else { 
      var %c = $findfile(%x,$+(*.,$3),0,aline -p @files $1-) 
      return %c 
    }
  }
}
menu @files { 
  dclick:run $gettok($sline($active, 1),1-,32)
}

Comments

Sign in to comment.
dataprofile   -  Sep 14, 2007

Thanks simplicity I\'ll add the option.

 Respond  
simplicity   -  Sep 14, 2007

Effective and clean. On the contrary, it\'s pretty simple. I recommend adding the option to delete the file. /remove should do the trick. I probably would give this a 5/10 if I had the option to rate snippets.

 Respond  
dataprofile   -  Sep 12, 2007

*updated:

added the option to run the selected file on a double-click

 Respond  
dataprofile   -  Sep 12, 2007

Alrighty, I edited the snippet.I just decided to make it a file list. Thank you xDaeMoN and kerstt for your feedback.

 Respond  
xDaeMoN   -  Sep 12, 2007

Also, there is $isfile and $exists.

 Respond  
dataprofile   -  Sep 12, 2007

Yes it does. On the contrary, this snippet returns the file in a specified directory. That covers if the directory is true. As said in the intro, this is a more advanced version of $findfile.

 Respond  
kerstt   -  Sep 12, 2007

$isdir(dirname)

Returns $true if the specified directory exists, otherwise $false.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.