I’m a beginner in Powershell and am trying to construct scripts to assist with learning. I’ve been using the Microsoft Powershell site which has been a great help with learning cmdlets, but I’m now at the stage where I’m trying to combine commands in order to achieve multiple actions in a script (still veerrrryy basic stuff :-).
I have the following:
- A folder called Pics, containing .jpg files
- A folder called Archives, containing .zip files
- A .txt file containing the filenames of the Archives directory, with ".zip" removed
- Rename all items in the Pics folder using the list contained in the .txt file
- Rename all items in the Pics folder using the filenames in the Archive folder, removing ".zip" in the process
I’ve not been able to find a working combination of Get-Content, Get-ChildItem and Rename-Item (possibly by losing the original value of $_ when piping into another command?) so wondering if I would need to achieve this using variables and loops or is there a way it can be achieved using basic cmdlets?