Hello all,
Is there a way I can set a variable as a repeating integer of variable repetitions?
As in, could I replace the wildcard in “DSC*0” with something that only reads for zeros?
Context:
I am using this script to copy a list of photos into a subfolder.
$E = "DSC*0" Get-Content .\list.txt | Foreach-Object { copy-item -Path "$E$_.jpg" -Destination ".\subfolder"}
This will copy the files in the list, but because of the way the variable is structured, it also copies any other photo with the last digits matching the number in the list.
ie: With range of photos DSC00001:DSC00301, the number ‘2’ in ‘list.txt’ will result in the following copies in the subfolder: DSC00002, DSC00102, DSC00202.
Whereas I want it to only copy the photo DSC00002.
I can circumvent the problem by adding zeros before the number in the list but there I think there must be a way to handle it in the script.
Hopefully that all makes sense. Let me know if I can make it clearer.
Thanks in advance.