简体   繁体   English

如何显示全名的长度

[英]how to display the length of a FULLNAME

how can i get the length of the full path of a filename?

I am getting all the files recursively in a directory structure succesfully, and now I am trying to get the length of the fullpath: 我成功地以递归方式将所有文件获取到目录结构中,现在我试图获取完整路径的长度:

get-childitem y:\ -rec | where {!$_.PSIsContainer} |
select-object FullName, LastWriteTime, $($_.fullname).length | export-csv -notypeinformation -delimiter '|' -path file.csv

my issue is with this: $($_.fullname).length : 我的问题是这样的: $($_.fullname).length

Select-Object : Null parameter. Expecting one of the following types: {System.String, System.Management.Automation.Scri ptBlock}. At line:2 char:14
+ select-object <<<<  FullName, LastWriteTime, $($_.fullname).length | export-csv -notypeinformation -delimiter '|' -pa th file.csv
    + CategoryInfo          : InvalidArgument: (:) [Select-Object], NotSupportedException
    + FullyQualifiedErrorId : DictionaryKeyUnknownType,Microsoft.PowerShell.Commands.SelectObjectCommand

how would i get the length of the fullname of the file? 我如何获取文件全名的长度?

Create a custom expression in the select cmdlet. 在select cmdlet中创建一个自定义表达式。 Like this: 像这样:

get-childitem y:\ -rec | where {!$_.PSIsContainer} |
select-object FullName, LastWriteTime, @{n="FullNameLength";e={ $_.fullname.length }} |
export-csv -notypeinformation -delimiter '|' -path file.csv

n = name and e = expression. n =名称, e =表达式。 You can also use their full name. 您也可以使用其全名。 l or label is an alternative to name . llabelname的替代方法。 No mather which way you write them, you end up with a custom property. 不管用哪种方式编写它们,最终都会得到一个自定义属性。 : ) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM