Article: Why I use the D programming language for scripting
Виталий Фадеев
vital.fadeev at gmail.com
Tue Feb 2 03:53:43 UTC 2021
On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:
> It's finally out!
>
> https://opensource.com/article/21/1/d-scripting
If the article is about scripting, then the article will contain
examples of scripts used in business.
For example, to delete all dub caches in a directory:
Version via Windows .bat:
@echo off
FOR /D %%f IN ( .\* ) DO (
IF EXIST .\%%f\.dub (
echo .\%%f\.dub
rmdir /q /s .\%%f\.dub
)
)
Version via Dlang:
module dubcache;
import std.file;
import std.path;
import std.stdio;
void main( string[] args )
{
foreach( dir; dirEntries( args[0].dirName,
SpanMode.shallow ) )
{
if ( dir.baseName == ".dub" )
{
writeln( "REMOVED: ", dir );
rmdirRecurse( dir.name );
}
}
}
or
module dubcache;
import std;
void main( string[] args )
{
dirEntries( args[0].dirName, SpanMode.shallow )
.filter!( a => a.baseName == ".dub" )
.each!(
( a )
{
writeln( a );
rmdirRecurse( a );
}
);
}
More information about the Digitalmars-d-announce
mailing list