Batch Script Explanations (For Cycle) -


i working on batch script find folder in directory, , got working, found questions on stackoverflow, however, though it's working should, have few question.

for /d /r "%directory%" %%a in (*) if /i "%%~nxa"=="%foldername%" set "folderpath=%%a" echo "%folderpath%" 

what %%a, (*) , %%-nxa lines for?

similarly in code (searches file in directory)

for /r "%directory%" %%a in (*) if "%%~nxa"=="%filename%" set p=%%~dpnxa 

what %%~dpnxa do?

as far google goes, unable find explanations, or official ms sites.

excerpt for :

in addition, substitution of variable references has been enhanced. can use following optional syntax:      %~i         - expands %i removing surrounding quotes (")     %~fi        - expands %i qualified path name     %~di        - expands %i drive letter     %~pi        - expands %i path     %~ni        - expands %i file name     %~xi        - expands %i file extension     %~si        - expanded path contains short names     %~ai        - expands %i file attributes of file     %~ti        - expands %i date/time of file     %~zi        - expands %i size of file     %~$path:i   - searches directories listed in path                    environment variable , expands %i                    qualified name of first 1 found.                    if environment variable name not                    defined or file not found                    search, modifier expands                    empty string 

%%a token used in loop,%%~nxa (on each iteration correspond processed file) name , extension of file. * wild card means every symbol.

wildcards- http://ss64.com/nt/syntax-wildcards.html

for loop - http://ss64.com/nt/for.html


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -