- 1 year ago
How to modify the Date Modified in Bulk?
To modify the Date Modified attribute of files in bulk, you can use PowerShell. Here's an example of how you can achieve this:
powershell# Set the base directory path
$basePath = "C:\Path\to\folder"
# Get all files in the base directory and its subdirectories
$files = Get-ChildItem -Path $basePath -Recurse | Where-Object { $_.PSIsContainer -eq $false }
# Set the new Date Modified value (replace with your desired date and time)
$newDateModified = Get-Date "2023-05-23 12:00 PM"
# Loop through each file and modify the Date Modified attribute
foreach ($file in $files) {
$file.LastWriteTime = $newDateModified
}
In this example, you need to specify the base directory path ($basePath
) where the files are located. The script uses the Get-ChildItem
cmdlet with the -Recurse
parameter to retrieve all files in the base directory and its subdirectories.
Next, you set the desired Date Modified value by assigning a new date and time to the $newDateModified
variable. Make sure to replace the sample date and time with your desired value.
Finally, a foreach
loop iterates over each file in the $files
collection and modifies the LastWriteTime
attribute to the new Date Modified value.
Run this PowerShell script, and it will update the Date Modified attribute of all files in the specified directory and its subdirectories.