|
Answer» I require "my_test" to process EVERY file with the extension XYZ. Unfortunately some of them have the HIDE attribute set, and are not seen by FOR.
I can firstly do "ATTRIB -H" so that everything is visible, but afterwards I would LIKE all attributes to be restored as they were, i.e. only hiding the files which were previously hidden.
Several times I have driven myself to brain-fade by reading the extensive documentation upon FOR. Every time a understand a little more, and then decide the reminder is tomorrow's MIGRAINE ! !
I would appreciate advice upon any of the special features and option switches that would help me, or a "SUPER_FOR" command, or perhaps a short and simple vb-script I could use that would find all files and invoke my_test.cmd upon each.
Regards Alan use attrib -h and get those hidden files to a new file... after processing, read that new file line by line and attrib+h back Thanks, but I already stated I could use attrib -h. I really need to use a suitable FOR option switch, or a vb-script.
I am exploring the habitat of system files; the Windows version of the ancient mariners maps "where dragons be". ! !
File "permissions" can impose various restrictions, and I suspect that I may be able to see the existence of some files, but NOT make a copy (e.g. files like pagefile.sys)
Any change to any file may RESULT in System Restore intercepting and putting a copy in Restore. When I ALLOWED Disc Cleanup to perform its default "compress old files", Windows File Protection demanded my Windows Installation C.D. and would accept no excuses. I really do not want to make Windows angry with me ! !
Regards Alan
what about:
Code: [Select]for /f "tokens=*" %%A in ('dir *.XYZ /b /a') do my_test %%A BC_Programmer
Thank you very much - Perfect Solution.
N.B. I have used DOS V3.32 onwards. I have always used DIR * /A:-D to see all files regardless of attributes. I was surprised by your use of /A.
I have now inspected DIR /? and can see that [:] is optional, so /A:-D is the same as /AD I can also see that no specific attribute needs to be included. I was not aware this was optional. I am surprised to observe that I can see all directories and files regardless of attributes with /A Back to SCHOOL for me ! !
FOR /F %%A IN ('COMMAND') is something I had problems with some months ago. I was never sure whether I should be using forward quotes or back quotes, i.e. keyboard top left or just left of #
When I viewed FOR /? I saw Quote FOR /F ["options"] %VARIABLE IN ('command') DO command [command-parameters] or, if usebackq option present: FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]
and I assumed the "usebackq option present" was something pre-existing, either by an option switch when launching CMD.EXE or by a registry hack.
I now realise, after scrolling down a page, it is not a pre-existing thing, but a special modifier within the optional options.
Time for my aspirins ! !
Thank you for your solution, which has led me into a less incomplete understanding of DIR and FOR.
Regards Alan
|