Her ay için (yyyy_mm
biçiminde) ve her bir klasörün alt klasörlerinin her birinde belirli bir yol (birinci parametre) klasörlerinde oluşturulan bir komut dosyası oluşturdum (biçim yyyy_mm_dd
)).Tüm yıl boyunca ay klasörleri ve gün alt klasörleri oluşturma
Kod çalışıyor, ancak daha kolay bir çözüm var mı?
param(
[string]$inppath = '',
[string]$inpyear = '0'
)
function dayfolder
{
1..[DateTime]::DaysInMonth($inpyear,$month) | ForEach-Object {
$day = $_
New-Item -ItemType directory -Force -Path ($inppath + '\' + $inpyear + '_' + ("{0:D2}" -f $month) + '\' + $inpyear + '_' + ("{0:D2}" -f $month) + '_' + ("{0:D2}" -f $day)) }
}
if ($inppath -eq '')
{
echo 'No path in input! First parameter!'
}
else
{
if ($inpyear -eq '0')
{
echo 'No year in input! Second parameter! Format: YYYY'
}
else
{
1..12 | ForEach-Object {
$month = $_
New-Item -ItemType directory -Force -Path ($inppath + '\' + $inpyear + '_' + ("{0:D2}" -f $month))
dayfolder
}
}
}
Çok teşekkürler! bu kadar kolay! –