Skip to main content

存在チェック.フォルダ(directoryexists、ディレクトリ)

Python

py
os.path.isdir(dname)

PHP

php
is_dir($file)

意味的には以下だが、 なければ false になってくれるので is_dir() だけで問題なさそう。

php
file_exists($file_or_dir) && is_dir($dir)

Bash

bash
if [ -d "$dname" ]; then ..

Ruby

rb
FileTest.directory?(dname)

意味的にはこうだが、 なければ false になってくれるので directory?() だけで問題なさそう。

rb
FileTest.exist?(file_or_dir) && FileTest.file?(dname)

PowerShell

powershell
(Test-Path $repodir) -and ! (Get-Item "$repodir").PSIsContainer