File Information

By Aucun50 on May 26, 2010

Little script I made a while back, doesn't really have any use.

Right click in any channel or status window and open the dialog. When your in the dialog double click on any file to bring up a easy to read dialog with the information.

alias -l scanner {
  if ($1) {
    var %dir = $1
    if ($2 && $2 != blank) { var %search = $2 }
    else { var %search = $chr(42) }
    var %files = 1
    did -r scanner 1
    did -a scanner 1 **** Directory: %dir ****
    while ($findfile(%dir,%search,0) >= %files) {
      var %file = $findfile(%dir,%search,%files)
      if ($3) {
        var %file.made = $+($chr(40),Made:,$chr(32),$duration($calc($ctime - $file(%file).ctime)),$chr(41))
        var %file.size = $+($chr(40),Bytes:,$chr(32),$file(%file).size,$chr(41))
        var %file.access = $+($chr(40),Last Used:,$chr(32),$duration($calc($ctime - $file(%file).atime)),$chr(41))
        did -a scanner 1 $gettok(%file,$numtok(%file,92),92) %file.made %file.size %file.access
      }
      else {
        if ($calc($numtok(%file,92) - 1) == $numtok(%dir,92)) {
          var %file.made = $+($chr(40),Made:,$chr(32),$duration($calc($ctime - $file(%file).ctime)),$chr(41))
          var %file.size = $+($chr(40),Bytes:,$chr(32),$file(%file).size,$chr(41))
          var %file.access = $+($chr(40),Last Used:,$chr(32),$duration($calc($ctime - $file(%file).atime)),$chr(41))
          did -a scanner 1 $gettok(%file,$numtok(%file,92),92) %file.made %file.size %file.access
        }
      }
      inc %files
    }
  }
}
dialog scanner {
  title "File Information"
  option dbu
  size -1 -1 400 220
  list 1, 5 5 390 150, vsbar, hsbar
  button "Update" 2, 5 155 50 10
  text "Directory" 3, 10 175 50 10
  edit "" 4, 40 172 350 10
  text "Search for..." 5, 10 190 50 10
  combo 6, 50 188 340 10
  radio "Starting with" 7, 10 205 50 10
  radio "Ending with" 8, 60 205 50 10
  text "" 9, 200 205 50 10
  button "Select Directory" 10, 60 155 60 10
  check "Add Subfolder Files" 11, 110 205 70 10
}
on *:dialog:scanner:*:*: {
  if ($devent == sclick) {
    if ($did == 2) { 
      if ($did(4)) {
        if (!$did(6)) {
          if ($did(11).state == 1) {
            scanner $shortfn($did(4)) blank subfolders
          }
          else {
            scanner $shortfn($did(4)) 
          }
        }
        else if ($did(6)) {
          if ($did(7).state == 1) {
            if ($did(11).state == 1) {
              scanner $shortfn($did(4)) $+($did(6),$chr(42)) subfolders
            }
            else {
              scanner $shortfn($did(4)) $+($did(6),$chr(42))
            }
          }
          else if ($did(8).state == 1) {
            if ($did(11).state == 1) {
              scanner $shortfn($did(4)) $+($chr(42),$did(6)) subfolders
            }
            else {
              scanner $shortfn($did(4)) $+($chr(42),$did(6))
            }
          }
        }
        did -ra scanner 9 $calc($did(1).lines - 1) files      
      }
    }
    else if ($did == 10) { 
      var %select = $sdir($mircdir,Select Directory)
      did -ra scanner 4 %select
    } 
  }
  else if ($devent == init) {
    did -a scanner 9 0 files
  }
  else if ($devent == close) {
    .remove scanner.ini
  }
  else if ($devent == dclick) {
    if ($gettok($did(1).seltext,1,32) == ****) { halt }
    if ($did(4)) {
      set %find $findfile($did(4),$gettok($did(1).seltext,1,32),1)
      set %file.made $file(%find).ctime
      set %file.size $file(%find).size
      set %file.access $file(%find).atime
      dialog -m file.info file.info
    }
  }
}
dialog file.info {
  title "File information"
  option dbu
  size -1 -1 180 55
  text "" 1, 5 5 170 40
  text "" 2, 5 25 170 20
  text "" 3, 5 35 170 20
  text "" 4, 5 45 170 20
}
on *:dialog:file.info:*:*: {
  if ($devent == init) {
    did -a file.info 1 Location: $remtok(%find,$gettok(%find,$numtok(%find,92),92),1,92)
    did -a file.info 2 Made: $duration($calc($ctime - %file.made)) ago
    did -a file.info 3 Size: %file.size bytes
    did -a file.info 4 Last used: $duration($calc($ctime - %file.access)) ago
  }
  else if ($devent == close) {
    unset %find %file.*
  }
}

menu channel,status { 
  Scanner:$iif($dialog(scanner),dialog -v scanner,dialog -m scanner scanner)
}

Comments

Sign in to comment.
Jethro   -  May 26, 2010

You have a lot of ifs. Well, you can make use of the && opeator to reduce them and save yourself some brackets. Nice effort you have put into the work.

 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.