Comment obtenir le volume d'un dossier spécifié directement en utilisant JSL ?Par exemple, ce dossier :
C:\Windows
Merci!
Organisation du contenules fenêtresRe : Comment obtenir le volume d'un dossier spécifié directement à l'aide de JSL ?Je ne crois pas qu'il puisse être dérivé directement.Voici ce que j'ai trouvé
Names Default To Here( 1 );
theList = Files In Directory( "C:\Windows" );
totSize = 0;
For Each( {theFile}, theList,
totSize = Sum( totSize, File Size( "C:\Windows\" || theFile ) )
);
Show( totSize );
Mais cela ne semble pas exact
Re : Comment obtenir le volume d'un dossier spécifié directement à l'aide de JSL ?Merci Jim!
Re : Comment obtenir le volume d'un dossier spécifié directement à l'aide de JSL ?Re : Comment obtenir le volume d'un dossier spécifié directement à l'aide de JSL ?Il serait peut-être préférable d'effectuer ce type de vérification en utilisant Exécuter le programme et une commande avec.
Avec Files In Directory, vous devrez ajouter recursive(1) (ou effectuer une boucle vous-même, pour obtenir des fichiers dans des dossiers).
Names Default To Here(1);
lookup_dir = "C:\Windows\";
file_list = Files In Directory(lookup_dir, recursive(1));
file_sizes = Transform Each({cur_file}, file_list,
File Size(lookup_dir || cur_file)
);
sum(file_sizes);
https://www.jmp.com/support/help/en/17.0/#page/jmp/file-functions.shtml?os=win&source=application#ww4951479
Vous pouvez également utiliser l'importation de fichiers multiples pour cela Arborescence des répertoires : explorer l'espace utilisé par les dossiers
Re : Comment obtenir le volume d'un dossier spécifié directement à l'aide de JSL ?Comme @jthi suggéré, voici une façon de le faire en utilisant Run Program / Powershell (de JMP, bien sûr).
/*JMP STATISTICAL DISCOVERY LLC (“JMP”) PERMITS THE USE OF THIS COMPUTER SOFTWARE CODE (“CODE”) ON AN AS-IS BASIS AND AUTHORIZES YOU TO USE THE CODE SUBJECT TO THE TERMS LISTED HEREIN. BY USING THE CODE, YOU AGREE TO THESE TERMS. YOUR USE OF THE CODE IS AT YOUR OWN RISK. JMP MAKES NO REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRIGEMENT, AND TITLE, WITH RESPECT TO THE CODE.
You may use the Code solely as part of a software product you currently have licensed from JMP, JMP’s parent company SAS Institute Inc. (“SAS”), or one of JMP’s or SAS’s subsidiaries or authorized agents (the “Software”), and not for any other purpose. The Code is designed to add functionality to the Software but has not necessarily been tested. Accordingly, JMP makes no representation or warranty that the Code will operate error-free. JMP is under no obligation to maintain, support, or continue to distribute the Code.
Neither JMP nor its licensors shall be liable to you or any third-party for any general, special, direct, indirect, consequential, incidental, or other damages whatsoever arising out of or related to your use or inability to use the Code, even if JMP has been advised of the possibility of such damages. Except as otherwise provided above, the Code is governed by the same agreement that governs the Software. If you do not have an existing agreement with JMP or SAS governing the Software, you may not use the Code.
JMP and all other JMP Statistical Discovery LLC product or service names are registered trademarks or trademarks of JMP Statistical Discovery LLC in the USA and other countries. ® indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies.
*/
Names Default To Here( 1 );
op = {};
rp = Run Program(
Executable( "powershell.exe" ),
Options( "ls c:\temp\ -r | measure -sum Length" ), //Replace c:\temp\ with your folder
ReadFunction( Function( {this}, Insert Into( op, this << read ) ) )
);
for each ({i}, op,
if (word(1, i) == "Sum", totalsize = num(regex (i, "([0-9]+)")))
);
show (totalsize);Re : Comment obtenir le volume d'un dossier spécifié directement en utilisant JSL ?Désormais, GPT-4o est très puissant, il peut faire de la programmation ordinaire :
Dans le système win10, la taille du volume de chaque répertoire du disque C (y compris les fichiers cachés), les exigences spécifiques sont :
En partant des répertoires racine du lecteur C,
1, si le sous-répertoire de ce répertoire comporte plus de 3 couches, il peut être étendu au répertoire de troisième couche, statistiques du volume respectif de chaque répertoire contenu dans le répertoire de troisième couche
2, si le sous-répertoire de ce répertoire ne dépasse pas 3 couches, les statistiques d'expansion de ce répertoire jusqu'à la dernière couche du répertoire du volume respectif
t1=tick seconds();run program(executable("cmd.exe"),options({"/c powershell -Command \!"& {$results = @(); Get-ChildItem C:\ -Directory -Force | ForEach-Object { $topDir = $_; $subDirs = Get-ChildItem $topDir.FullName -Recurse -Directory -Force -ErrorAction SilentlyContinue | Where-Object { ($_.FullName.Split('\').Length - 1) -le 3 }; if ($subDirs) { $subDirs | ForEach-Object { $size = (Get-ChildItem $_.FullName -Recurse -File -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum; $results += [PSCustomObject]@{ Path = $_.FullName; 'Size (MB)' = [math]::Round($size / 1MB, 2) } } } else { $size = (Get-ChildItem $topDir.FullName -Recurse -File -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum; $results += [PSCustomObject]@{ Path = $topDir.FullName; ')' = [math]::Round($size / 1MB, 2) } } }; $results | Export-Csv -Path 'D:\目录大小.csv' -NoTypeInformation -Encoding UTF8}\!""}));
t2=tick seconds();t=t2-t1;Re : Comment obtenir le volume d'un dossier spécifié directement en utilisant JSL ?