Move-Item -Path $zipFile. $destinationPath = Join-Path $sourceFolder $zipFileName $zipFilePath = Join-Path $destinationFolder $zipFileNameĬompress-Archive -Path $fileList.FullName -DestinationPath $zipFilePath $zipFileName = "New_Drawings_$(Get-Date).AddDays(-1).ToString('yyyy-MM-dd').zip" Here is a basic example: date (Get-Date).AddDays (-1) Rename-Item -Path C:\Example.txt -NewName 'C:\Example (date.ToString ('yyyyMMdd')). # Create a new zip file with yesterday's date in the name If I understood your question correctly, you need to format your datetime object as a string. $fileList = Get-ChildItem -Path $sourceFolder -Recurse -Filter $extensionFilter | Where-Object Rename that shortcut to Windows PowerShell (bootstrap) and then move it to the Start. # Get the list of files that match the extension filter in the source folder and its subfolders and haven't been processed before So you can simply download the file or script from GitHub using. New-Item -Path $processedFilesFile -ItemType File # Check if the processed files file exists and create it if it doesn't $processedFilesFile = "C:\mydestination\folder\myProcessedFiles.txt" $zipFileName = "New_Drawings_$(Get-Date -Format 'yyyy-MM-dd').zip" $destinationFolder = "C:\mydestination\folder" The script runs it generates a text file for the list of files but is empty and does not copy any files either.Įventually I want this to run in task scheduler # Set variables The script is also designed to check if file have already been copied and skip over those files. The intent is for the script to look for a specific drawing file in my source folder and move them to another folder. Rename files with PowerShell The Rename-Item cmdlet enables you to change the name of an object while leaving its content intact.
0 Comments
Leave a Reply. |