 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
kiu
Joined: 18 Dec 2005 Posts: 229 Location: Italy - Galatro(RC)
|
Posted: Tue Apr 25, 2006 10:19 pm Post subject: kiu Print Folder: subproject of AHkxplorer |
|
|
This program will let you print(to a txt file) a folder content including or not inclunding its own subfolders.
Another useful thing for developers is the use of a label to emulate the possibility to use recursive functions
As always, please send feedback
| Code: | /*
Author:
Salvatore Agostino Romeo
E-Mail:
romeo84@gmail.com
Description:
This program will let you print(to a txt file) a folder content
with or without its own subfolders.
Version:
0.5
License:
GPL
Note:
SubProject of AHKxplorer
ToDo:
?
Bugs:
?
*/
Gui, Add, Edit, x6 y35 w190 h20 vselectedFolder,
Gui, Add, Button, x206 y35 w20 h20 gBtnSelFolder, ...
Gui, Add, Checkbox, x6 y65 w120 h20 vsubfolders, Include subfolders
Gui, Add, Button, x136 y65 w60 h20 gBtnStart, Start
Gui, Add, Text, x6 y5 w220 h30, Select a folder and press start`nYou can use Drag and Drop
Gui, Add, Button, x206 y65 w20 h20 gEsc,X
Gui, Add, Text, x170 y10 w60 h20 vstatus cRed, Analyzing
Gui, Add, Text, x170 y10 w60 h20 vstatus2 cGreen, Done
GuiControl, Hide, status
GuiControl, Hide, status2
Gui, +AlwaysOnTop +ToolWindow
Gui, Show, x270 y264 h94 w236 ,Print folder - romeosa.com
Return
BtnSelFolder:
FileSelectFolder, tempfolder, , , Select the folder to print
GuiControl, , selectedFolder, %tempfolder%
return
BtnStart:
Gui, submit, nohide
if(subfolders)
printFolderWithSubfolders(selectedFolder)
else
printFolderWithoutSubfolders(selectedFolder)
return
GuiDropFiles:
GuiControl, , selectedFolder, %A_GuiControlEvent%
return
Esc::
GuiClose:
ExitApp
return
printFolderWithoutSubfolders(folder)
{
global
GuiControl, Hide, status2
GuiControl, Show, status
SetBatchLines, -1
Process, Priority, , H
FileDelete , %folder%_cont-sub_%A_DD%-%A_MM%.txt
Loop, %folder%\*, 2
print=%print%+--+>%A_LoopFileName%`n
Loop, %folder%\*
print=%print%+--->%A_LoopFileName%`n
FileAppend, %tempFolder%`n+`n%print%, %folder%_cont-sub_%A_DD%-%A_MM%.txt
Sleep,200
Run, %folder%_cont-sub_%A_DD%-%A_MM%.txt
print=
GuiControl, Hide, status
GuiControl, Show, status2
return
}
printFolderWithSubfolders(folder)
{
global
GuiControl, Hide, status2
GuiControl, Show, status
SetBatchLines, -1
Process, Priority, , H
print(folder)
FileDelete , %folder%_cont_%A_DD%-%A_MM%.txt
Loop, Parse , print , `n
{
StringTrimLeft, last, A_LoopField , 5
end=%end%%last%`n
}
FileAppend, %tempFolder%`n+`n%end%, %folder%_cont_%A_DD%-%A_MM%.txt
Sleep,200
Run, %folder%_cont_%A_DD%-%A_MM%.txt
print=
end=
GuiControl, Hide, status
GuiControl, Show, status2
return
}
print(folder)
{
global
printTag=%printTag%--+
Loop, %folder%\*, 2
{
print=%print%%printTag%--+>
print=%print%%A_LoopFileName%`n
subfolder=%A_LoopFileFullPath%
gosub, printSubFolder
}
if (A_Index = 0)
StringTrimRight, tag, tag, 3
Loop, %folder%\*
{
print=%print%%printTag%---->
print=%print%%A_LoopFileName%`n
}
StringTrimRight, printTag, printTag, 3
; msgbox, %print%
return
}
printSubFolder:
print(subFolder)
return |
_________________ ____________________
______________________
kiu |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Tue Apr 25, 2006 10:40 pm Post subject: |
|
|
Have you tried the DIR command? With the right parameters (set in the GUI) it could save you the print functions. | Code: | dir = C:\t\AutoHotKey
par = /s /A:D
runwait %comspec% /c dir %par% %dir% > !dir.txt,,Hide
run !dir.txt |
|
|
| Back to top |
|
 |
kiu
Joined: 18 Dec 2005 Posts: 229 Location: Italy - Galatro(RC)
|
Posted: Wed Apr 26, 2006 7:20 am Post subject: |
|
|
Yes, I know, but look at the output: I think the output from my script is more readable.
Take a look at the difference:
My script
| Code: | E:\programmi\AutoHotkey\Extras\Editors
+
+>EditPlus
+---->AutoHotkey.ctl
+---->AutoHotkey.stx
+---->Run this to install syntax and cliptext files for EditPlus.ahk
+>Emacs
+---->ahk-mode.el
+>EmEditor
+---->ahk.esy
+>jEdit
+---->ahk.xml
+---->Run this to install syntax and clip files for jEdit.ahk
+>MED
+---->MEDMclHeader.txt
+---->MEDSynHeader.txt
+---->Run this to install syntax file for MED.ahk
+>Notepad++
+---->AHK Autohotkey.api
+---->Run this to install syntax file for Notepad++.ahk
+---->userDefineLang.xml
+>PSPad
+---->AutoHotkey.def
+---->AutoHotkey.ini
+---->Run this to install syntax and clip files for PSPad.ahk
+>SciTE
+---->ahk.properties
+>Syntax
+--+>Scripts
+--+---->Generate jEdit.ahk
+--+---->Generate PSPad.ahk
+--+---->Generate TextPad.ahk
+--+---->Validate master syntax files.ahk
+---->CommandNames.txt
+---->Commands.txt
+---->Functions.txt
+---->Keys.txt
+---->Keywords.txt
+---->Variables.txt
+>TextPad
+---->AutoHotkey.syn
+---->AutoHotkey.tcl
+---->Run this to install syntax and clip library files for TextPad.ahk
+>UltraEdit
+---->Operators.txt
+---->Run this to install syntax highlighting for UltraEdit.ahk
+---->Separators.txt
+---->Special.txt
+>Vim
+---->ahk.vim |
from cmd
| Code: | Il volume nell'unit… E Š Dati
Numero di serie del volume: 2882-3260
Directory di E:\programmi\AutoHotkey\Extras\Editors
26/01/2006 19.02 <DIR> .
26/01/2006 19.02 <DIR> ..
29/11/2005 12.47 <DIR> EditPlus
29/11/2005 12.47 <DIR> Emacs
29/11/2005 12.47 <DIR> EmEditor
29/11/2005 12.47 <DIR> jEdit
29/11/2005 12.47 <DIR> MED
28/01/2006 17.55 <DIR> Notepad++
29/11/2005 12.47 <DIR> PSPad
26/01/2006 19.02 <DIR> SciTE
29/11/2005 12.47 <DIR> Syntax
29/11/2005 12.47 <DIR> TextPad
29/11/2005 12.47 <DIR> UltraEdit
29/11/2005 12.47 <DIR> Vim
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\EditPlus
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\Emacs
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\EmEditor
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\jEdit
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\MED
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\Notepad++
28/01/2006 17.55 <DIR> .
28/01/2006 17.55 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\PSPad
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\SciTE
26/01/2006 19.02 <DIR> .
26/01/2006 19.02 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\Syntax
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
29/11/2005 12.47 <DIR> Scripts
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\Syntax\Scripts
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\TextPad
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\UltraEdit
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
0 File 0 byte
Directory di E:\programmi\AutoHotkey\Extras\Editors\Vim
29/11/2005 12.47 <DIR> .
29/11/2005 12.47 <DIR> ..
0 File 0 byte
Totale file elencati:
0 File 0 byte
41 Directory 18.259.947.520 byte disponibili
|
What do you think? _________________ ____________________
______________________
kiu |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Wed Apr 26, 2006 3:32 pm Post subject: |
|
|
| This is a matter of editing the output file, as a string. There are also options of the DIR command, which control the output format, like /B (removing clutter). The Sort options and the attribute selections are really handy, too. I like the format with the /D option, but you can give the user options in the GUI selecting any of these. I regularly use a simpler form of this to create a batch file to do something (like renaming, moving...) on many files. |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Wed Apr 26, 2006 3:56 pm Post subject: Re: kiu Print Folder: subproject of AHkxplorer |
|
|
| kiu wrote: | Another useful thing for developers is the use of a label to emulate the possibility to use recursive functions | Code: | [snip]
print(folder)
{
global
printTag=%printTag%--+
Loop, %folder%\*, 2
{
print=%print%%printTag%--+>
print=%print%%A_LoopFileName%`n
subfolder=%A_LoopFileFullPath%
gosub, printSubFolder
}
[snip]
}
printSubFolder:
print(subFolder)
return |
|
This leave me perplexed...
What are the advantages over calling print(subFolder) directly in the print function? (providing the proper use of local variables inside this function)
(Example of recursive function) _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Last edited by PhiLho on Thu Apr 27, 2006 12:40 pm; edited 1 time in total |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 385 Location: Texas, USA
|
Posted: Wed Apr 26, 2006 5:20 pm Post subject: |
|
|
The old DOS tree command also gives good results:
Them be my thoughts... |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|