new transfer tasks and fixed permissions

This commit is contained in:
abrown38 committed 2025-03-21 14:13:13 +00:00
1 parent f1541c6f29
commit dc1afab15f
7 files changed
+122 -18

No files matched your search

@@ -1 +1 @@
scheduled_transfer_export_v1.3.ps1
scheduled_transfer_export_v2.0.ps1
@@ -0,0 +1,40 @@
function Main {
$log_file="T:\Logs\Export-Log.txt"
$export_dirs=Get-ChildItem -Path "S:\" -Directory -Recurse -Filter "Export"
foreach($export_dir in $export_dirs) {
$full_path="$($export_dir.FullName)"
$parent_dir="$($export_dir.Parent)"
$files=Get-ChildItem -path $full_path -File
foreach($file in $files) {
$file_path="$($file.FullName)"
$destination="T:\Export\$parent_dir\"
$size=Format-FileSize(($file_path).length)
Move-Item -Path $file_path -Destination $destination
$date=Get-Date -UFormat "[%d/%b/%y %T]"
$log_line="{0} {1} -> {2} [{3}]"-f $date, $file_path, $destination, $size
Write-Host $log_line
$log_line | out-file $log_file -Append
}
}
}
function Format-FileSize() {
Param ([int64]$size)
If ($size -gt 1TB) {[string]::Format("{0:0.00} TB", $size / 1TB)}
ElseIf ($size -gt 1GB) {[string]::Format("{0:0.00} GB", $size / 1GB)}
ElseIf ($size -gt 1MB) {[string]::Format("{0:0.00} MB", $size / 1MB)}
ElseIf ($size -gt 1KB) {[string]::Format("{0:0.00} kB", $size / 1KB)}
ElseIf ($size -gt 0) {[string]::Format("{0:0.00} B", $size)}
Else {[string]::Format("0B", $size)}
}
Main
@@ -1 +1 @@
scheduled_transfer_import_v1.3.ps1
scheduled_transfer_import_v2.0.ps1
@@ -0,0 +1,43 @@
function Main {
$import_dir="T:\Import\"
$log_file="T:\Logs\Import-Log.txt"
$files=Get-ChildItem -Path $import_dir -File -Recurse -Force -Exclude ".*"
foreach($file in $files) {
$file_name="$($file.Name)"
$parent_dir="$($file.Directory.Name)"
$Destination="S:\" + "$parent_dir" + "\import"
$size=Format-FileSize(($file).length)
$date=Get-Date -UFormat "[%d/%b/%y %T]"
if([System.IO.File]::Exists("$Destination\$file_name")) {
$log_line="{0} {1} already exists at {2}"-f $date, $file_name, $destination, $size
Write-Host $log_line
$log_line | out-file $log_file -Append
continue;
}
Move-Item -path $file -Destination $Destination
$log_line="{0} {1} -> {2} [{3}]"-f $date, $file, $destination, $size
Write-Host $log_line
$log_line | out-file $log_file -Append
}
}
function Format-FileSize() {
Param ([int64]$size)
If ($size -gt 1TB) {[string]::Format("{0:0.00} TB", $size / 1TB)}
ElseIf ($size -gt 1GB) {[string]::Format("{0:0.00} GB", $size / 1GB)}
ElseIf ($size -gt 1MB) {[string]::Format("{0:0.00} MB", $size / 1MB)}
ElseIf ($size -gt 1KB) {[string]::Format("{0:0.00} kB", $size / 1KB)}
ElseIf ($size -gt 0) {[string]::Format("{0:0.00} B", $size)}
Else {[string]::Format("0B", $size)}
}
Main