Ciao Mi piacerebbe creare un file batch per ottenere tutte le sotto-cartelle. Qualcuno, per favore aiutami su questo?loop through sottocartelle
risposta
Questo è banale in entrambi i file batch o PowerShell:
lotto:
for /r %%x in (*.sql) do (
rem "(or whatever)"
sqlcmd "%%x"
)
PowerShell:
Get-ChildItem -Recurse -Filter *.sql |
ForEach-Object {
sqlcmd $_.FullName # or whatever
}
Ciao @ Joey, esiste un metodo che utilizza sqlcmd per scorrere tutte le sottocartelle senza codificare il percorso delle sottocartelle? e per lo script PowerShell l'ultima riga, potresti fornire un esempio per questo "sqlcmd $ _ # o qualsiasi altra cosa"? grazie mille –
Ecco uno script PowerShell che uso per ottenere la dimensione del " Scuola "all'interno della sottocartella delle cartelle home di ciascun utente. IE. N: \ nomeutente \ UserNameOSXProfile \ Scuola
SizeOfSchoolFolder.ps1
$schoolFolderTotalSize=0
$foundChildren = get-childitem *\*OSXProfile\School
foreach($file in $foundChildren){
$schoolFolderTotalSize = $schoolFolderTotalSize + [long](ls -r $file.FullName | measure -s Length).Sum
}
switch($schoolFolderTotalSize) {
{$_ -gt 1GB} {
'{0:0.0} GiB' -f ($_/1GB)
break
}
{$_ -gt 1MB} {
'{0:0.0} MiB' -f ($_/1MB)
break
}
{$_ -gt 1KB} {
'{0:0.0} KiB' -f ($_/1KB)
break
}
default { "$_ bytes" }
}
ho tirato i numeri aggiungendo da: Adding up numbers in PowerShell
E la dimensione della cartella facendo apparire bella: Get Folder Size from Windows Command Line
E \ * \ * OSXProfile \ School come ricerca per una sottocartella specifica. Limit Get-ChildItem recursion depth
di sostituire 'xyz' con 'abc' in tutti i nomi di file:
Get-ChildItem -Recurse -Filter *.mp3 | Rename-Item –NewName { $_.name –replace 'xyz','abc' }
- 1. loop through JPanel
- 2. jQuery loop through json?
- 3. C++ Loop through Map
- 4. loop through celle nell'intervallo denominato
- 5. ConvertFrom-JSON Loop Through oggetto
- 6. jQuery loop through data() oggetto
- 7. jQuery loop through Divs bambino
- 8. While Loop to Iterate through Database
- 9. UIImage Loop Through Pixel altamente inefficiente?
- 10. Loop through System.Collections.Generic.Dictionary via per dichiarazione
- 11. Loop through month in SQL Server
- 12. Facebook graph API loop through paging
- 13. Loop through a ArrayList di HashMaps Java
- 14. Python: loop through list item x times?
- 15. Loop through per il ciclo% x% di volte nel lotto
- 16. Loop through array durante la rimozione degli elementi
- 17. "Loop through" data.table per calcolare le medie condizionali
- 18. GetDIBits e loop through pixel utilizzando X, Y
- 19. rails has_many: through has_many: through
- 20. C#: Cycle through encodings
- 21. come eseguire il rendering di oggetti json in jade e loop through dei risultati
- 22. Tabella Loop through DataTables per ottenere il contenuto di tutte le celle
- 23. Loop through valori o chiave del Registro di sistema. _winreg Python
- 24. Rails polymorphic has_many: through
- 25. Iterate through DataSet
- 26. activerecord find through association
- 27. Iterating through viewgroup
- 28. Django M2MFields 'through' widgets
- 29. Python 'except' fall-through
- 30. Has_Many: Through o: finder_sql
rendere la vostra mente ... vuoi un file batch o uno script PowerShell? – Joey