Created
May 18, 2018 02:23
-
-
Save bondurantdt/8afcb3a392500695bdc32ddc57d3881a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
#Dependencies: rclone (latest beta, or >1.42 configured to Google Drive and S3), powershell | |
#Process: Deletes existing items in path, uses rclone to grab all files in a specific folder | |
#(configured with 'rclone config' command), | |
#exports those files from Google Drive to PDF, using a couple | |
#arrays, renames the PDFs to | |
#the Google Drive File ID, then copies to S3. | |
## | |
$dt = Get-Date -format "MMddyyyy" | |
$log = "FileMover_$dt.log" | |
$log = "<yourpath>" + $log | |
Start-Transcript $log | |
$path = '<yourpath>' | |
rm $path\*.* | |
$googlefileid = @() | |
$filearray = @() | |
#lsf --format "i" added from here: https://github.com/ncw/rclone/pull/1476 | |
$googlefileid += rclone lsf --format "i" <yourGoogleDrive>:/ | |
rclone copy <yourGoogleDrive>:/ $path --drive-formats pdf --log-file=<yourpath>\sync-$dt.log --log-level INFO | |
$files = Get-ChildItem -Path:$path -File | ForEach-Object -Process: { | |
$filearray += $_.Name | |
} | |
$filearray 2>&1 | |
for($i = 0; $i -lt $googlefileid.Length; $i++) | |
{ | |
$oldfile = $filearray[$i] | |
$newfile = $googlefileid[$i]+".pdf" | |
Rename-Item -path "$path\$oldfile" -NewName "$path\$newfile" -WhatIf 2>&1 | |
Rename-Item -path "$path\$oldfile" -NewName "$path\$newfile" 2>&1 | |
} | |
rclone copy $path <s3bucket> --log-file=<yourpath>\sync-$dt.log --log-level INFO | |
Stop-Transcript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment