Corrected many "./" path entries to $($PSScriptRoot).

This commit is contained in:
serialexperiments0815 2025-10-18 16:59:55 +02:00
commit 9dc9824b12
9 changed files with 17 additions and 17 deletions

View file

@ -8,7 +8,7 @@
# (Get-Item $file).LastWriteTime = $oldDate
# (Get-Item $file).LastAccessTime = $oldDate
Get-ChildItem ".\" -Recurse |
Get-ChildItem "$($PSScriptRoot)" -Recurse |
Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} |
Remove-Item -Force -WhatIf

View file

@ -1,5 +1,5 @@
# Export all file and folder path to folderFileList.csv
# Select-Object FullName property was chosen to only export the full path.
Get-ChildItem -Path "./" -Recurse |
Get-ChildItem -Path "$($PSScriptRoot)" -Recurse |
Select-Object -Property FullName |
Export-Csv -Path "./folderFileList.csv" -NoTypeInformation
Export-Csv -Path "$($PSScriptRoot)/folderFileList.csv" -NoTypeInformation

View file

@ -5,21 +5,21 @@
[String[]]$pictureFormat = "jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp", "heic", "heif", "raw", "cr2", "nef", "arw", "svg", "ico"
[String[]]$documentFormat = "pdf", "doc", "docx", "odt", "rtf", "txt", "csv", "xls", "xlsx", "ods", "ppt", "pptx", "odp", "md", "html", "xml"
$filesInFolder = Get-ChildItem -Path "./" -File
$filesInFolder = Get-ChildItem -Path "$($PSScriptRoot)" -File
foreach($file in $filesInFolder){
$extension = $file.Extension.TrimStart('.').ToLower()
if ($videoFormat -contains $extension){
Move-Item -Path $file.FullName -Destination "./videos/$($file.Name)"
Move-Item -Path $file.FullName -Destination "$($PSScriptRoot)/videos/$($file.Name)"
}
elseif ($pictureFormat -contains $extension) {
Move-Item -Path $file.FullName -Destination "./pictures/$($file.Name)"
Move-Item -Path $file.FullName -Destination "$($PSScriptRoot)/pictures/$($file.Name)"
}
elseif ($documentFormat -contains $extension) {
Move-Item -Path $file.FullName -Destination "./documents/$($file.Name)"
Move-Item -Path $file.FullName -Destination "$($PSScriptRoot)/documents/$($file.Name)"
}
}

View file

@ -1,6 +1,6 @@
# File searches for txt files and replaces specified string.
$textFiles = Get-ChildItem -Path "./" -Filter *.txt
$textFiles = Get-ChildItem -Path "$($PSScriptRoot)" -Filter *.txt
$searchText = 'this text is false'
$replaceText = 'this text is true'
foreach($textFile in $textFiles){

View file

@ -3,5 +3,5 @@
# As the -Filter parameter only matches folders at current level, not recursively in all subfolders.
$nameOfFolder = "important"
$directionOfFolder = Get-ChildItem -Path "./" -Recurse -Directory | Where-Object { $_.Name -eq $nameOfFolder }
Copy-Item -Path $directionOfFolder.FullName -Destination (Join-Path "./safe/" $directionOfFolder.Name) -Recurse -Force
$directionOfFolder = Get-ChildItem -Path "$($PSScriptRoot)" -Recurse -Directory | Where-Object { $_.Name -eq $nameOfFolder }
Copy-Item -Path $directionOfFolder.FullName -Destination (Join-Path "$($PSScriptRoot)/safe/" $directionOfFolder.Name) -Recurse -Force