(http://www.xn--lrka-loa.com/progressbar/Search_Folder.png) |
| C:\*.cmd |
/* Script: Find all files in specified directory and subdirectories to destination (folder) and create a folder with shadows on the desktop for it. */
currdir = strip( DIRECTORY(), 'T', '\' )
numwords = 0
CALL rxFuncAdd "SysLoadFuncs" , "RexxUtil" , "SysLoadFuncs"
CALL SysLoadFuncs
CALL RxFuncAdd "MKey","MKey","MKey"
CALL SysCls
IF ARG() = 0 THEN
Return Usage()
IF ARG(1) = '' THEN
pattern = '*'
ELSE DO
from = STRIP( FILESPEC( 'D', ARG(1) )||FILESPEC( 'P', ARG(1) ), 'T', '\' )
pattern = FILESPEC( 'N', ARG(1) )
END
IF from = '' THEN
from = DIRECTORY()
CALL rxBusy 'Loading, one moment please...', 0
elapsed = TIME( 'R' )
wp_folder = SysTempFileName( 'WP_SEARCH_???' )
If SysCreateObject( "WPFolder", ARG(1), "<WP_DESKTOP>", "OBJECTID=<"||wp_folder||">;ICONFILE="||DIRECTORY()||"\Search_Folder.ICO" ) then
IF SysOpenObject( '<'||wp_folder||'>', DEFAULT, 1 ) THEN
CALL processPath from, pattern, 0, 1
CALL rxProgress 1, 2
CALL DIRECTORY currdir
EXIT 0
processPath: PROCEDURE EXPOSE elapsed counter_ wp_folder
wp_source = ARG(1)
wp_pattern = ARG(2)
progress = ARG(3)
chunk = ARG(4)
CALL SysFileTree wp_source||'\*', 'folder', 'DO'
CALL SysFileTree wp_source||'\'||wp_pattern, 'file', 'FO'
IF MKey( 1000 ) = 1 THEN
PARSE PULL dont_process_this_folder
ELSE DO j = 1 to folder.0
IF TIME( 'E' ) > 1 + elapsed THEN DO
CALL rxBusy 'Processing '||folder.j, 0
CALL rxProgress progress + ( j - 1 ) / ( folder.0 + file.0 ) * chunk, 2
elapsed = TIME( 'E' )
END
wp_star_pos = POS( '*', wp_pattern )
counter = 1
DO WHILE wp_star_pos > 0
wp_pattern = SUBSTR( wp_pattern, 1, wp_star_pos - 1 )||'"pre.'||counter||'"'||SUBSTR( wp_pattern, wp_star_pos + 1 )
counter = counter + 1
wp_star_pos = POS( '*', wp_pattern )
END
counter = counter - 1
INTERPRET 'PARSE VALUE folder.j WITH "'||wp_pattern||'"'
IF LENGTH( pre.counter ) > 0 & counter > 0 THEN
call SysCreateShadow folder.j,'<'||wp_folder||'>'
CALL processPath folder.j, ARG(2), progress + ( j - 1 ) / ( folder.0 + file.0 ) * chunk, chunk / ( folder.0 + file.0 )
END
DROP folder.
DO i = 1 to file.0
IF TIME( 'E' ) > 1 + elapsed THEN DO
CALL rxBusy 'Processing '||wp_source, 0
CALL rxProgress progress + ( j + i - 1 ) / ( j + file.0 ) * chunk, 2
elapsed = TIME( 'E' )
END
rc = SysCreateShadow( file.i, '<'||wp_folder||'>' )
END
DROP file.
RETURN
/* part, of_total, display_on_row */
rxProgress: PROCEDURE
IF DATATYPE( ARG(1), 'N' ) THEN
DO
progress = MIN( TRUNC( 76 * ARG(1) ), 76 )
CALL rxOut LEFT( COPIES( '█', progress )||COPIES( '?', 76 - progress ), 76 )||RIGHT( TRUNC( 100 * ARG(1) )||'%', 4 ), ARG(2)
END
Return 0
rxBusy: PROCEDURE EXPOSE counter_
SELECT
WHEN counter_ = 1 THEN
CALL rxOut '/ '||ARG(1), ARG(2)
WHEN counter_ = 2 THEN
CALL rxOut '- '||ARG(1), ARG(2)
WHEN counter_ = 3 THEN
CALL rxOut '\ '||ARG(1), ARG(2)
OTHERWISE
counter_ = 0
CALL rxOut '| '||ARG(1), ARG(2)
END
counter_ = counter_ + 1
Return 0
/* text, display_on_row */
rxOut: PROCEDURE
IF DATATYPE( ARG(2), 'W' ) THEN
PARSE VALUE SysCurPos( ARG(2), 0 ) with prev_row prev_col
SAY LEFT( ARG(1), 80 )
IF DATATYPE( ARG(2), 'W' ) THEN
CALL SysCurPos prev_row, prev_col
Return 0