# Instructions - Modifying Folder Date-Stamps # (a) Create CSV file with 3 fields # FolderName : name of folder to modify # DLdate : date in yyyy-mm-dd format to be assigned to the folder # DBcat : Category field (field must exist but may be left blank) # Sample file - notice only need " if there are any commas. Spaces are OK. # FolderName,Dldate,Dbcat # Miles Davis - 1958 Spotlight Lounge,2004-10-31,Jazz # MilesDavis5-PlayboyJF-Chicago-1959-08-07.flac,2004-10-31,Jazz # "Reuben Wilson - 1996-02-01 & 1996-03-26 SOBs, New York City",2004-10-31,Jazz # # (b) Update the variables in the first section below # CSVfilename: The CSV file's path & filename # Create4, Modify5 & Access6: For Date Created, Date Modified and Date Accesses, respectively, # enter "yes" or "no" whether to update folder's date stamp. # ReviewOutput: Pause processing for review after that number of lines (or 0 for no pauses) # ---------- Edit these user parameters --------------- $CSVfilename = ".\csvlist20190928.csv" $Create4 = "yes" $Modify5 = "yes" $Access6 = "yes" $ReviewOutput = 0 # -----------End user parameters ---------------------- Write-Host "Starting..." # Import the CSV file $MyFolderList = Import-Csv $CSVfilename # Set counters $vCounterUpdated = 0 $vCounterReview = 0 foreach($FolderDetails in $MyFolderList) { $Name1 = $FolderDetails.FolderName $Date2 = $FolderDetails.Dldate $Cat3 = $FolderDetails.Dbcat if ( $Date2 -eq '1900-01-00') { # Write-Host "Skipped (date)" $Vcat " " $Vdate " " $Vfoldername } else { # check if folder exists $vTestpath = Test-Path $Name1 if ( $vTestpath -eq 'True') { $a = get-item $Name1 if ( $Create4 -eq "yes" ) { $a.CreationTime = $Date2 } if ( $Modify5 -eq "yes" ) { $a.LastWriteTime = $Date2 } if ( $Access6 -eq "yes" ) { $a.LastAccessTime = $Date2 } $vCounter = $vCounter + 1 $vCounterReview = $vCounterReview + 1 Write-Host "----- UPDATED $Date2 $Cat3 " Write-Host $Name1 } else { # Don't do anything if skipped: not a subfolder! } } if ( $vCounterReview -eq $ReviewOutput ) { $Name = Read-Host "Review files processed OR Press return to continue" Write-Host " " $vCounterReview = 0 } } #------------END Function SetFolderDate --------------- Write-Host "............... " Write-Host "Processed $vCounter records" $Name = Read-Host "Processing complete. Press enter when done"