Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
Abra todos los archivos en la carpeta y vuelva a guardarlos en un directorio de carpeta creado según el nombre del archivo

Hola, tengo más de 15K archivos PDF guardados en una carpeta Z:\Archivo PDF\2010

y necesitan una mejor organización. No tengo idea de cómo hacer esto, pero lo que me gustaría que sucediera es: Si el nombre del archivo es 8757854.pdf

Me gustaría crear (si aún no existe) el directorio Z:\PDF Archive\8700000-8799999\8750000-8759999\

y copie el archivo en él.

La mayoría de los nombres de archivo tienen 7 dígitos, pero hay algunos que solo tienen 6, en esa situación, me gustaría agregar un 0 al comienzo del nombre del archivo.

Entonces, si el nombre del archivo es 757854.pdf, esta sería la ruta del archivo: Z:\PDF Archive\0700000-0799999\0750000-0759999\

¡Los pensamientos y las ideas serían muy apreciados! ¡Gracias de antemano!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Prueba lo siguiente:

 # Input and output (root) directory paths. $inPath = 'Z:\PDF Archive\2010' $outPathRoot = 'Z:\PDF Archive' # The max. number of digits in the input file names. $maxDigits = 7 Get-ChildItem -LiteralPath $inPath -Filter *.pdf | ForEach-Object { # Left-pad the number string that constitutes the base file name # with zeros to ensure a length of 7. $paddedNum = $_.BaseName.PadLeft($maxDigits, '0') # Construct the name of the subdirectories to copy the files to, # replacing the digits after the leading 2 and 3 digits first with "0" and "9", # respectively, joining the resulting strings with "-" $subDirs = foreach ($leadingDigits in $paddedNum.Substring(0, 2), $paddedNum.Substring(0, 3)) { ($leadingDigits + '0' * ($maxDigits - $leadingDigits.Length)), ($leadingDigits + '9' * ($maxDigits - $leadingDigits.Length)) -join '-' } # Create the output subdirectories, if necessary. # -Force both creates parent directories on demand and # quietly returns an existing directory, if present. $targetDir = New-Item -Type Directory -Force ($outPathRoot + '\' + ($subDirs -join '\')) # Copy the PDF file at hand to the target subdirectory. $_ | Copy-Item -Destination $targetDir.FullName }

Nota: Si agrega el parámetro común -WhatIf al comando Copy-Item , obtendrá una vista previa de las operaciones de copia, que incluirá la ruta de destino completa.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda