PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
-
Kazun
Re: PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
Get-help Get-ChildItem -Path cert:\
SYNTAX
Get-ChildItem [[-Path] ] [[-Filter] ] [-Exclude ] [-Force] [-Include ] [-Name
] [-Recurse] [-UseTransaction []] []
Get-ChildItem [[-Filter] ] [-Exclude ] [-Force] [-Include ] [-Name] [-Recurse] -Literal
Path [-UseTransaction []] []
Get-ChildItem [-CodeSigningCert] [-DnsName ] [-EKU ] [-ExpiringInDays ] [-SSLServerAuthenticat
ion] []
PS > Get-help Get-ChildItem -Path cert:\ -Parameter CodeSigningCert
-CodeSigningCert []
Gets only those certificates with code-signing authority. This parameter gets certificates that have "Code Signing
" in their EnhancedKeyUsageList property value.
PS > Get-help Get-ChildItem -Parameter CodeSigningCert
Get-help : No parameter matches criteria CodeSigningCert.
At line:1 char:1
+ Get-help Get-ChildItem -Parameter CodeSigningCert
Так что не соглашусь с данным заявлением.
ЗЫ. Для FileSystem - Get-help Get-ChildItem -Path C:\ -Parameter ReadOnly
SYNTAX
Get-ChildItem [[-Path] ] [[-Filter] ] [-Exclude ] [-Force] [-Include ] [-Name
] [-Recurse] [-UseTransaction []] []
Get-ChildItem [[-Filter] ] [-Exclude ] [-Force] [-Include ] [-Name] [-Recurse] -Literal
Path [-UseTransaction []] []
Get-ChildItem [-CodeSigningCert] [-DnsName ] [-EKU ] [-ExpiringInDays ] [-SSLServerAuthenticat
ion] []
PS > Get-help Get-ChildItem -Path cert:\ -Parameter CodeSigningCert
-CodeSigningCert []
Gets only those certificates with code-signing authority. This parameter gets certificates that have "Code Signing
" in their EnhancedKeyUsageList property value.
PS > Get-help Get-ChildItem -Parameter CodeSigningCert
Get-help : No parameter matches criteria CodeSigningCert.
At line:1 char:1
+ Get-help Get-ChildItem -Parameter CodeSigningCert
Так что не соглашусь с данным заявлением.
ЗЫ. Для FileSystem - Get-help Get-ChildItem -Path C:\ -Parameter ReadOnly
-
Foreigner
Re: PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
В PowerShell v2 - командлет Get-Help работает странно, поэтому используют Get-Command:
http://www.nivot.org/blog/post/2010/...amicParameters
-
Kazun
Re: PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
Для начала не плохо бы озвучить версию PowerShell: The ReadOnly parameter was introduced in Windows PowerShell 3.0.
PS > Get-help Get-ChildItem -Path C:\ -Parameter ReadOnly
-ReadOnly []
Gets only read-only files and directories (folders).
To get only read-only items, use the ReadOnly parameter, its "ar" alias, or the ReadOnly value of the Attributes pa
rameter. To exclude read-only items, use the Attributes parameter.
Все мои примеры v3 и выше.
PS > Get-help Get-ChildItem -Path C:\ -Parameter ReadOnly
-ReadOnly []
Gets only read-only files and directories (folders).
To get only read-only items, use the ReadOnly parameter, its "ar" alias, or the ReadOnly value of the Attributes pa
rameter. To exclude read-only items, use the Attributes parameter.
Все мои примеры v3 и выше.
-
Kazun
Re: PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
Kazun,
Код:
Тот же результат выдает $PSVersionTable.PSVersion
Код:
Код:
Код: Выделить всё
> $host.version
Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1Тот же результат выдает $PSVersionTable.PSVersion
Код:
Код: Выделить всё
> get-host
Name : ConsoleHost
Version : 4.0
InstanceId : 92980ac2-ee31-4e9a-a070-7bd0a2cc2e08
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : ru-RU
CurrentUICulture : ru-RU
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace-
Kazun
Re: PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
Цитата Foreigner:
Просто пронумеровать? Без названия? Я переименовываю исходя из тегов (с помощью taglib-sharp). Ваш вариант:
данный вариант применим к другим типам файлов ?или что мешает при смене типа файлов на PDF переименовывать файлы?
Просто пронумеровать? Без названия? Я переименовываю исходя из тегов (с помощью taglib-sharp). Ваш вариант:
PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
данный вариант применим к другим типам файлов ?или что мешает при смене типа файлов на PDF переименовывать файлы?
-
Iska
Re: PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
Kazun, кошмар. Ну, хотя бы так
.
.-
IVa_
Re: PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
Цитата Foreigner:
Ничего не мешает
Ничего не мешает
PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
Код: Выделить всё
PS C:\Users\TEMP> $dirs = gci "C:\Users\MOC\Desktop\pdf\" -dir -recurse
foreach ($dir in $dirs) {
if ( test-path "$($dir.fullname)\*.pdf" ) {
$files = gci $dir.fullname '*.pdf'
1..$files.count | % { rename-item -lit $files[($_-1)].fullname "$( '{0:d3}' -f $_ ).pdf" }
}}
Get-ChildItem : Не удается найти параметр, соответствующий имени параметра "dir".
строка:1 знак:45
+ $dirs = gci "C:\Users\MOC\Desktop\pdf\" -dir <<<< -recurse
+ CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBind
ingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Command
s.GetChildItemCommand-
IVa_
Re: PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
IVa_, Значит ваша версия PowerShell ниже 4-й или даже 3-й:
Код:
Код:
Код: Выделить всё
$dirs = gci "C:\Users\MOC\Desktop\pdf\" -recurse | where { $_.psiscontainer }
foreach ($dir in $dirs) {
if ( test-path "$($dir.fullname)\*.pdf" ) {
$files = gci $dir.fullname '*.pdf'
1..$files.count | % { rename-item -lit $files[($_-1)].fullname "$( '{0:d3}' -f $_ ).pdf" }
}}-
Foreigner
-
IVa_
Re: PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
Цитата IVa_:
До четвертой обновить не получается(
Старайтесь. Мне, на XP, понятно — никак. А Вам можно.
До четвертой обновить не получается(
PowerShell - [решено] нужно переименовать большую коллекцию MP3 файлов
Старайтесь. Мне, на XP, понятно — никак. А Вам можно.