windows - Print File Descriptions from all files in a folder, wmic command -


this works

for /r "d:\folder\" %i in (*) @echo %i 

but doesn't

for /r "d:\folder\" %i in (*) @wmic datafile name=%i description 

using reference first command, wrote wmic command. doesn't work.

gives multiple errors...

node - <machine name> error: description = invalid query 

what's problem here. how print file descriptions of files in folder.

update: added '' around %i

for /r "d:\folder\" %i in (*) @wmic datafile name='%i' description 

now gives me no instance(s) available. error?

question: why wmic datafile description doesn't give file description in file properties dialog box? how file description.

enter image description here

you same output , lot faster using

dir /s /b "d:\folder\*" 

but, question how queries wmic each file

@echo off     setlocal enableextensions disabledelayedexpansion      /r "d:\folder" %%a in (*) (         set "folder=%%~pa"         /f "tokens=* delims=." %%x in (".%%~xa") (             setlocal enabledelayedexpansion             %%b in ("!folder:\=\\!") (                 endlocal                  wmic datafile ^                   "drive='%%~da' , path='%%~b' , filename='%%~na' , extension='%%~x'" ^                 description | find ":"             )         )     ) 

this code handles 2 "problems" in wmic queries: paths need have backslashes doubled , file extension stored without starting dot.

edited seems op needs metadata file contents , not data available wmic,

@if (@this==@isbatch) @then  @echo off     setlocal enableextensions disabledelayedexpansion      call :listfilesproperties "d:\folder"     goto :eof  :listfilesproperties folder         cscript //nologo //e:jscript "%~f0" "%~f1"     goto :eof  @end   var foldernamespace = wscript.createobject("shell.application").namespace(wscript.arguments.item(0));      (         var fileenum = new enumerator(foldernamespace.items());         !fileenum.atend();         fileenum.movenext()     ){         var filename = fileenum.item();         var fullpath = foldernamespace.getdetailsof(filename, 180);         var title  = foldernamespace.getdetailsof(filename, 21);         wscript.echo( fullpath + '|' + title );     }; 

this hybrid batch/jscript file retrieve properties of files in indicated folder, in case full path , file title.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -