$ dir1 = "c：\ path \ to \ dir1"
    $ dir2 = "c：\ path \ to \ dir2"

    get -childitem $ dir1 -recurse -filter *.csv |foreach-object {
        $ file_path_in_dir1 = $ _。fullname
        $ file_path_in_dir2 = $ _。fullname.replace（$ dir1、$ dir2）

        ＃対応するファイルが$ dir2に存在するかどうかを確認します
        if（test-path $ file_path_in_dir2）{
            ＃2つのファイルパスでcmd1.exeを実行します
            cmd1.exe $ file_path_in_dir1 $ file_path_in_dir2
        } それ以外 {
            書き込みwarning「対応するファイル$ dir2：$ file_path_in_dir2」で見つかりません」
        }
    }
$dir1 = "C:\path\to\dir1"
    $dir2 = "C:\path\to\dir2"

    Get-ChildItem $dir1 -Recurse -Filter *.csv | ForEach-Object {
        $file_path_in_dir1 = $_.FullName
        $file_path_in_dir2 = $_.FullName.Replace($dir1, $dir2)

        # Check if the corresponding file exists in $dir2
        if (Test-Path $file_path_in_dir2) {
            # Run cmd1.exe with the two file paths
            cmd1.exe $file_path_in_dir1 $file_path_in_dir2
        } else {
            Write-Warning "Corresponding file not found in $dir2: $file_path_in_dir2"
        }
    }