0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Googleフォトを一括DLした後に写真だけ取り出したい

Posted at

Googleフォトを一括DLした後に写真だけ取り出したい

Googleフォトで容量がかつかつになって一括DLしたのはいいけど、フォルダ階層は多いわjsonファイルは多いわで大変だと思います。
それを解決する

前提

ダウンロードするとzipファイルになっていると思うので、これは展開してコピー元のフォルダにすべて入れてください。
また、写真を保存するコピー先パスを作成してください。

やること

以下のps1をたたくのじゃ

$sourceRoot = "Z:\Google Photo\source"  # コピー元のパスに置き換えてください
$targetRoot = "Z:\Google Photo\target"  # コピー先のパスに置き換えてください
$extensions = @(".jpg", ".JPG", ".mp4")

$files = Get-ChildItem -Path $sourceRoot -Recurse -File | Where-Object {
    $extensions -contains $_.Extension
}

foreach ($file in $files) {
    $baseName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name)
    $ext = $file.Extension
    $destinationPath = Join-Path $targetRoot $file.Name
    $i = 1

    while (Test-Path $destinationPath) {
        $destinationPath = Join-Path $targetRoot "$baseName ($i)$ext"
        $i++
    }

    Copy-Item -Path $file.FullName -Destination $destinationPath
}

ps1ファイルが実行できないじゃと?
PowerShellで次のコマンドで実行するのじゃ(gphoto.ps1という名前にしています)

powershell -ExecutionPolicy Bypass -File "Z:gphoto.ps1"

これで面倒な作業は楽になるはずです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?