batch for loop is not displaying needed components -
have following , correct.. cannot use the /f construct.. %%g works correctly.
edit - not on work computer, seeing same results.. so, took d3f4ult's code:
@echo off echo current directory: %cd% rem 22310611 /f %%g in ( 'dir /b /a-d "c:\11\*"' ) ( echo f = %%~fg echo d = %%~dg echo p = %%~pg echo n = %%~ng echo x = %%~xg echo s = %%~sg echo = %%~ag echo t = %%~tg echo z = %%~zg pause ) and result is:
current directory: c:\batch f = c:\batch\!kix.zip d = c: p = \batch\ n = !kix x = .zip s = c:\batch\!kix.zip = t = z = press key continue . . . issues seen are: c:\batch folder executing script c:\11 target folder trying information from..
variable issues: p incorrect a,t,z not populated
let's make proposed change suggested..
@echo off echo current directory: %cd% rem 22310611 rem - original: /f %%g in ( 'dir /b /a-d "c:\11\*"' ) ( %%g in ( c:\11\* ) ( echo f = %%~fg echo d = %%~dg echo p = %%~pg echo n = %%~ng echo x = %%~xg echo s = %%~sg echo = %%~ag echo t = %%~tg echo z = %%~zg pause ) and results are:
current directory: c:\batch c:\batch>fllist.bat current directory: c:\batch f = c:\11\!kix.zip d = c: p = \11\ n = !kix x = .zip s = c:\11\!kix.zip = --a------ t = 07/31/2011 08:29 z = 25732801 press key continue . . . hope helps understanding of issue is.
see if code below works you, if possible post output of happens there you, using code.
code:
@echo off rem 22310611 /f %%g in ( 'dir /b /a-d "d:\logs\*"' ) ( echo f = %%~fg echo d = %%~dg echo p = %%~pg echo n = %%~ng echo x = %%~xg echo s = %%~sg echo = %%~ag echo t = %%~tg echo z = %%~zg pause ) pause output
f = d:\logs\1.jpg d = d: p = \logs\ n = 1 x = .jpg s = d:\logs\1.jpg = --------- t = 10/03/2014 16:55 z = 128928
Comments
Post a Comment