其他分享
首页 > 其他分享> > wmic 操作文件的datafile

wmic 操作文件的datafile

作者:互联网

wmic datafile /?
动词有ASSOC,CALL,CREATE,DELETE,GET,LIST 这几个

命令:
wmic datafile where "filename='dsc04059' and extension='jpg' and drive='f:'" list /format:value

结果:
AccessMask=18809343
Archive=TRUE
Caption=f:\dsc04059.jpg
Compressed=FALSE
CompressionMethod=
CreationClassName=CIM_LogicalFile
CreationDate=20091012174149.578125+480
CSCreationClassName=Win32_ComputerSystem
CSName=20090621-1240
Description=f:\dsc04059.jpg
Drive=f:
EightDotThreeFileName=f:\dsc04059.jpg
Encrypted=FALSE
EncryptionMethod=
Extension=jpg
FileName=dsc04059
FileSize=86092
FileType=Kankan JPEG 图像
FSCreationClassName=Win32_FileSystem
FSName=NTFS
Hidden=FALSE
InstallDate=20091012174149.578125+480
InUseCount=
LastAccessed=20100412155336.781250+480
LastModified=20091009140702.000000+480
Manufacturer=
Name=f:\dsc04059.jpg
Path=\
Readable=TRUE
Status=OK
System=FALSE
Version=
Writeable=TRUE


实例:
DATAFILE – DataFile 管理
::查找e盘下test目录(不包括子目录)下的cc.cmd文件
wmic datafile where “drive=’e:’ and path=’\\test\\’ and FileName=’cc’ and Extension=’cmd’” list
::查找e盘下所有目录和子目录下的cc.cmd文件,且文件大小大于1K
wmic datafile where “drive=’e:’ and FileName=’cc’ and Extension=’cmd’ and FileSize>’1000′” list
::删除e盘下文件大小大于10M的.cmd文件
wmic datafile where “drive=’e:’ and Extension=’cmd’ and FileSize>’10000000′” call delete
::删除e盘下test目录(不包括子目录)下的非.cmd文件
wmic datafile where “drive=’e:’ and Extension<>’cmd’ and path=’test’” call delete
::复制e盘下test目录(不包括子目录)下的cc.cmd文件到e:\,并改名为aa.bat
wmic datafile where “drive=’e:’ and path=’\\test\\’ and FileName=’cc’ and Extension=’cmd’” call copy “e:\aa.bat”
::改名c:\hello.txt为c:\test.txt
wmic datafile “c:\\hello.txt” call rename c:\test.txt
::查找h盘下目录含有test,文件名含有perl,后缀为txt的文件
wmic datafile where “drive=’h:’ and extension=’txt’ and path like ‘%\\test\\%’ and filename like ‘%perl%’” get name

标签:文件,datafile,cmd,drive,wmic,test,where
来源: https://www.cnblogs.com/hyyx/p/13935965.html