Hola
Este Script es el hermano de
este otro Script (http://foro.elhacker.net/scripting/aporte_batch_files2list-t412507.0.html), genera un archivo de texto que contiene la lista de estructura de carpetas del directorio de trabajo y de sus subdirectorios, el directorio de trabajo se puede modificar en las variables del Script, y la lista de capetas se registra usando la ruta relativa de los archivos de dicho directorio de trabajo.
El Script tiene 2 métodos de listar las carpetas, que son: 1. Listado normal, y 2. Listado incluyendo carpetas ocultas.
El Script tiene la funcionalidad de medir el tiempo transcurrido de la operación.
Todo lo que he mencionado se puede configurar en las variables que están documentadas con comentarios de ayuda en el código.
· Una imagen de muestra:(http://img545.imageshack.us/img545/7966/m6sv.png)
· El código:Folders2List.cmd
REM =================
REM Console Settings:
REM =================
Title Folders2List - By Elektro
Mode
Con Cols=150 Lines=50
CHCP 1252 1
>NUL & REM Windows-1252, Spanish-Latin.
REM =====
REM Info:
REM =====
Echo ------------------------------------------------------------------------------------------------------------------------------------
Echo This script writes a textfile containing the relative paths of the folder structure at the working directory and it's subdirectories
Echo ------------------------------------------------------------------------------------------------------------------------------------
REM ====================
REM User defined values:
REM ====================
REM This value indicates the directory where to list it's folder structure.
REM This value indicates the resulting folder list.
Set "OutputFile=
%CD%\Folders.txt"
REM This value indicates how the hidden folders are threated when listing the folder structure.
REM True = List folders and also folders with the 'hidden' attribute.
REM False = List only normal folders without the 'hidden' attribute.
Set "IncludeHiddenFolders=True"
REM =====
REM Main:
REM =====
:: Display starting info.
Echo [i] Working Directory...:
%WorkingDir% Echo [i] Output file.........:
%OutputFile% Echo [i] Include Hidden Files:
%IncludeHiddenFolders%
:: Call Methods.
Call :
ListFolders "
%IncludeHiddenFolders%"
:: Finish.
Echo [i] Listed Folders:
%FolderCount% folders.
Echo [i] Elapsed Time..:
%ElapsedTime%
REM ========
REM Methods:
REM ========
:StartTimer
Set "StartingDate=
%Date%"
Set "StarttingTime=
%Time:~0,-3%"
:StopTimer
(
Echo Minutes = DateDiff
^("n", "
%StartingDate% %StarttingTime%", Now
^) )>"%TEMP%\%~n0 MinuteDiff.vbs"
For /F "Tokens=*"
%%#
In ( 'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
)
:ListFolders
Echo [+] Collecting folders, this operation could take some minutes long, please wait...
If /I "
%~1"
EQU "True"
(Call :
ListHiddenFolders) If /I "
%~1"
EQU "False"
(Call :
ListNormalFolders)
:ListNormalFolders
(FOR /D /R "
%WorkingDir%"
%%#
in ("*"
) DO ( ))>"%OutputFile%"
:ListHiddenFolders
(FOR /F "Tokens=* Delims="
%%#
in ('
Dir /B /S /AD "
%WorkingDir%\*"'
) DO ( ))>"%OutputFile%"
REM ===============
REM Error Controls:
REM ===============
:CheckErrors
:: 'IncludeHiddenFolders' Value check.
If /I "
%IncludeHiddenFolders%"
NEQ "True"
If /I "
%IncludeHiddenFolders%"
NEQ "False"
( Echo [x] Error parsing parameter 'IncludeHiddenFolders',
Echo value '
%IncludeHiddenFolders%' is
not a Boolean value.
)
Pero, ¿A que viene la función del tiempo? xD
Es un simple capricho, la verdad es que el script trabaja rápido pero aun así me gusta saber cuanto tarda, estoy acostumbrado a medir el tiempo de ejecución en la programación
.NET para optimizar los procedimientos que den señales de conflictos en el tiempo de ejecución.
PD: Gracias por comentar.
Saludos!