Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Create Directory Listing - Explorer shell menu extension


  • Please log in to reply
2 replies to this topic
Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
This script is very simple, it creates a text file listing the contents of the directory you are in, in the directory you are in (Windows Explorer only.) Once the file is created it is opened.

I wrote this script to replace a batch file that did something similar (with two lines of code!) but without the date stamps and formatting.

This script is designed to be launched from the explorer shell menu and can be installed uncompiled by specifying the path to AutoHotkey.exe in the command line. Sample registry keys required to link it to the shell menu are posted below along with the source code.

Changelog:
* script does not write extra blank line if no folders found in directory
* directory list file is no longer added to directory listing

C:\Perl

bin
eg
html
lib
site

pod2htmd.tmp
pod2htmi.tmp


#notrayicon
#singleinstance force

ControlGetText, path, Edit1, ahk_class ExploreWClass
FormatTime, date, , yyMMdd

name = %path%/%date%%a_space%dir%a_space%list.txt
shortname = %date%%a_space%dir%a_space%list.txt

filedelete, %name%
fileappend, %path%`n`n, %name%

filelist = 
loop, %path%/*.*, 2 ; get only folders
  FileList = %FileList%%A_LoopFileName%`n
Sort, FileList
Loop, parse, FileList, `n
{
  fileappend, %A_LoopField%`n, %name%
}

fileappend, `n, %name%

filelist = 
loop, %path%/*.*, 0 ; get only files
  FileList = %FileList%%A_LoopFileName%`n
Sort, FileList
Loop, parse, FileList, `n
{
  IfNotEqual, A_LoopField, %shortname%
    fileappend, %A_LoopField%`n, %name% 
}

run, %name%
return

REGEDIT4

[HKEY_CLASSES_ROOT\*\shell\Create Directory Listing]
@="Create Directory Listing"

[HKEY_CLASSES_ROOT\*\shell\Create Directory Listing\Command]
@="X:\\DirListing.exe"

[HKEY_CLASSES_ROOT\Directory\shell\Create Directory Listing]
@="Create Directory Listing"

[HKEY_CLASSES_ROOT\Directory\shell\Create Directory Listing\Command]
@="X:\\DirListing.exe"

"Anything worth doing is worth doing slowly." - Mae West
Posted Image

x79animal
  • Members
  • 1021 posts
  • Last active: May 14 2013 04:21 PM
  • Joined: 01 May 2010
cant get the registry files to import, could someone try fix for windows7

bekihito
  • Members
  • 42 posts
  • Last active: Sep 04 2013 07:33 PM
  • Joined: 03 Feb 2010
Personaly I hate messing with the registry so I modified the input based on http://www.autohotke...light=directory

#notrayicon
#singleinstance force
SetWorkingDir, %A_ScriptDir%

AppTitle = Directory Lister
DefaultDirToList = %A_ScriptDir%

FormatTime, date, , ddMMMyyyy

FileSelectFolder, path , *%DefaultDirToList% , 2 ,  Select folder that you wish to list files and folders from - press ESC/Cancel to exit %AppTitle%

if errorlevel
{
    ExitApp
}

IfNotExist, %path%
{
   MsgBox, , %AppTitle%, Unable to find the selected path: %path%
   ExitApp
}

SplashTextOn, 300, 30, %AppTitle%, Reading files and folders from %path%

name = %path%\%date%%a_space%dir%a_space%list.txt
shortname = %date%%a_space%dir%a_space%list.txt

filedelete, %name%
fileappend, Listing directory:%path%`n ,%name%
fileappend, List file:%name%`n `n,%name%
fileappend, FOLDERS `n ,%name%
filelist =
loop, %path%/*.*, 2 ; get only folders
  FileList = %FileList%%A_LoopFileName%`n
Sort, FileList
Loop, parse, FileList, `n
{
  fileappend, %A_LoopField%`n, %name%
}

fileappend, FILES `n ,%name%

filelist =
loop, %path%/*.*, 0 ; get only files
  FileList = %FileList%%A_LoopFileName%`n
Sort, FileList
Loop, parse, FileList, `n
{
  IfNotEqual, A_LoopField, %shortname%
    fileappend, %A_LoopField%`n, %name%
}
SplashTextOff
run, %name%
return
Oh, one more thing: I erased the "recursively" because it doesn't do that (doesn't fetch the files from child folders), but it is a nice idea for next version.