How to? GLOBAL question

Apr 2, 2011
North Carolina, USA
I want to use GLOBAL on a whole drive but exclude a particiulr subtree. How is htis best handled?

C:\> SET nLen=%USERPROFILE\Favorites
C:\> GLOBAL /I /Q /H gosub fldr

IFF %@left[%nLen,%_CWD] != "%USERPROFILE\Favorites" THEN
.... process directory

TCC 15.01.52 x64 Windows 7 [Version 6.1.7601]
TCC Build 52 Windows 7 Build 7601 Service Pack 1
May 20, 2008
Elkridge, MD, USA
Essentially yes. You can simplify it thus (and be able to do it at the command line):

global /i /q /h if %@index[%_cwd,%userprofile\favorites] lt 0 process_this_directory

CAVEAT: not tested!
Apr 2, 2011
North Carolina, USA
global /i /q /h if isfile *.url if %@index[%_cwd,%userprofile\Favorites] lt 0 move /md /r /p *.url %userprofile\Favorites\URLs\

Works great; However What if I want to not transverse these trees:
C:\My Programs
C:\Program Files
C:\Program Files (x86)
C:\Users\All Users\Microsoft\Windows\Start Menu

Once I get this to work - I'll work on DOC and other "often" files.
May 20, 2008
Elkridge, MD, USA
Method 1 : create a file dir_list of all directory trees to be processed; then do
for %d in (@dir_list) (pushd %d %+ global ... %+ popd )
Method 2 : if there are NO hidden directories you want to actually process, use the method of the old EXCEPT command:
- create a file listing the top directory of each not to process tree: no_tree
- save the current state of their H attribute:
for /r %d in (@no_tree) if %attrib[@d,H] EQ 1 echo %d >! was_hidden
- HIDE them:
attrib a:-h +H @no_tree
- use GLOBAL without /H option:
global /i /q if isfile *.url if %@index[%_cwd,%userprofile\Favorites] lt 0 move /md /r /p *.url %userprofile\Favorites\URLs\
- unhide all that you hid above:
attrib -h @no_tree
- rehide as needed:
if isfile was_hidden attrib +H @was_hidden

BTW, it is possible to create just a list of directories which you had to actually hide, and only unhide those, possibly by the report of the ATTRIB command which hid them, saving a tiny bit of time.

Method 3 : Create a root-level directory, and populate it with symlinks or junctions to each tree to be actually processed. Now you can use GLOBAL in this directory. This is just an alternate implementation of the underlying principle of Method 1.

Method 4 : In the original GLOBAL method, check every directory's location against ALL possible excluded paths, instead of just one or two...

Comparison: Methods1 1 and 3 have difficulty if there is a directory which is to be processed but which has one or more subdirectories that are to be excluded, e.g., C:\users
May 20, 2008
Elkridge, MD, USA
I think so. The line after the ProcessFldr label should start with IFF, shouldn't it?
I think it would be simpler using an indirect file ("@file") of the list of directory trees to be ignored. This would do it (CAVEAT EMPTOR):

GLOBAL /H /I /Q gosub DO_IT

if not isfile *.url return
do dir in @ignore_list
  if %@index[%_cwd,%dir] GE 0 return
move ...
Similar threads
Thread starter Title Forum Replies Date
D Documentation Help "Startup" page does not describe global lists Support 0
WadeHatler Any way to disable ALL the global hotkeys? Support 8
vefatica GLOBAL /Q? Support 2
fpefpe How to? Global variable set /v Support 4
Patulus GLOBAL command is very slow Support 28
vefatica @SMOPEN and "Global\" Support 3
P Disable global hotkey Ctrl+Shift+T Support 19
vefatica Dumping global lists to the *sav files Support 17
vefatica GLOBAL Support 4
Stefano Piccardi parsing issue in command GLOBAL Support 3
vefatica Aliases global vs. local Support 12
D Directory history file and global directory history Support 23
mdwyer @replace - global use in a text file Support 3
C sharing global histories between different TCMD versions? Support 5
vefatica Sorting the global dir history Support 13
C forum Posting Question... Support 3
C question re: Move Support 3
S How to? Upgrade Question: What supporting documentation is required at time of purchase? Support 2
Peter Murschall Documentation Question to %@PSHELL Support 4
Fross Tab Question Support 6
Fross Quick Function Question Support 17
Dick Johnson Question about the Touch command Support 0
rps Documentation "Copy+Paste+run" question Support 2
vefatica SFTP question Support 17
vefatica Question about IPWorks Support 0
C How to? SHORTCUT question..... Support 6
vefatica TPIPE, crash and question Support 1
C Question / Suggestion Support 1
MickeyF Another TPIPE question Support 6
vefatica Another @EVERYTHING question Support 4
mikea How to? %@everything[] question Support 10
A License Question for Single User Support 5
Jay Sage Help Correction (and Related Question) Support 0
S Elapsed time in TCC prompt question Support 0
H command line parsing question Support 5
C Forum question Support 2
B Newbie here, I have a question. Support 4
J Dumb Question ... Support 4
Timothy Byrd Updating from TC 9 to TC 17 - TCTOOLBAR question Support 2
M A possibly stupid question about the "del" command... Support 7
M A just out of curiosity question re @DiskTotal Support 4
Fross Status Bar Time Question Support 1
A Stupid, obvious question - launch a BAT with TC Support 10
vefatica OT: VisualStudio question Support 1
vefatica Wildcard question Support 4
Dan Glynhampton v15 installer question Support 2
C Move question with Encrypted file... Support 6
M Maybe Maybe I'm being stupid (again), but a simple question... Support 4
C Message Board question Support 1
James Miller How to? filename completion question Support 1

Similar threads