File Lister/Indexer v0.2

By MaSOuD on Jun 18, 2010

By this snippet you can list/index a specific path with specific extension(s) to a text file. (Indexing duration depends on amount of folders/files you have and your PC speed.)

Usage: /findex [-nx] [Extension]
Example: /findex -nx *.mp3 D:Music

[-nx] properties and [Extension(s)] are optional.
n: To exclude the path which you enter with your command.
x: To index a specific file extension(s).
You can specify one or more file extension(s) to index them. (.txt;.jpg, etc... Separating by semicolon.)

You can simply copy/paste the code into your remote or downloading the .mrc file from HERE

Updated

  • There was a bug that it didn't index the files which are in the first root directory.
  • Now it supports multi extensions.
alias FIndex {
  ; The [-nx] and [Extension(s)] properties are optional.
  ; n: Use it if you want to exclude the path which you enter with your command.
  ; x: Use it if you want to index a specific file extension.
  ; You can specify one or more file extension(s) to index them. (*.txt;*.jpg, etc... Separating by semicolon.)
  var %path = $iif($left($1,1) == -,$iif(x isin $1,$3-,$2-),$1-)
  set %IndexerSPath $sdir($mircdir,Select a path to save your output file)
  set %IndexCount 0
  if (n isin $1) { set %IndexerNoPath %path }
  else { unset %IndexerNoPath }
  if ($isfile($qt(%IndexerSPath $+ Indexer.txt))) { 
    var %msg = The file is already exists! Do you want to replace it? $+ $crlf $+ YES $+ $chr(9) $+ = Replace the file. $+ $crlf $+ NO $+ $chr(9) $+ = Append the new info into the file. $+ $crlf $+ CANCEL $+ $chr(9) $+ = Do nothing, just return.
    var %q = $input(%msg,nvgq,File is already exists...)
    if (%q == $yes) { .write -c $+(",%IndexerSPath,Indexer.txt,") }
    elseif (%q == $no) { }
    elseif (%q == $cancel) return
  }
  if (!$1) || (!$isdir($qt(%path))) || (!%IndexerSPath) { echo $color(info) -a *** File Indexer Syntax: /findex [-nx] [Extension] <Path> | return }
  var %ext = *.*
  if ($left($1,1) == -) && (x isin $1) && (*.* iswm $2) { %ext = $2 }
  mWriteInfo -i Path: $qt(%path) $+ $crlf $+ Extension(s): $qt(%ext)
  set %IndexTime $ticks
  .noop $findfile(%path,%ext,0,0,mWriteInfo $1-)
  var %a = 1,%b = $finddir(%path,*.*,0)
  while (%a <= %b) {
    .noop $findfile($finddir(%path,*.*,%a),%ext,0,0,mWriteInfo $1-)
    inc %a
  }
  mWriteInfo -i Operation succeed in: $calc($calc($ticks - %IndexTime) / 1000) ms. $+ $crlf $+ Indexed files: %IndexCount $+ $crlf $+ E.O.F.
  echo $color(info) -a *** Operation succeed and File has been saved to $+(",%IndexerSPath,Indexer.txt,")
  unset %Index*
}

alias -l mWriteInfo {
  if (!$1) || (!%IndexerSPath) return
  if ($1 == -i) {
    .write $+(",%IndexerSPath,Indexer.txt,") $str(-,40)
    .write $+(",%IndexerSPath,Indexer.txt,") $2-
    .write $+(",%IndexerSPath,Indexer.txt,") $str(-,40)
  }
  else {
    if ($len(%IndexerNoPath) > 0) && ($right(%IndexerNoPath,1) != \) { set %IndexerNoPath $+(%IndexerNoPath,\) }
    .write $+(",%IndexerSPath,Indexer.txt,") $remove($1-,%IndexerNoPath)
    inc %IndexCount 1
  }
}

Comments

Sign in to comment.
MaSOuD   -  Mar 07, 2011

I'm so glad about that you found this useful :)

 Respond  
montague   -  Mar 06, 2011

i've been searching for something like this... thx a lot MaSOuD!

 Respond  
MaSOuD   -  Jun 19, 2010

Thanks dude :)

 Respond  
TheNitelyfe   -  Jun 18, 2010

dats some hot stuff man

 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.