I'm using Powershell and imagemagick to create a simple code to append images. I need to Powershell to be run from one folder, the input images to be take from a sub-folder, and the output images to be taken from a subfolder of that folder.
For example, the folder structure goes:
\image-converter\Append-images\Appended
So Powershell will be run from the "image-converter" folder, and will open with the directory: PS
C:\Users\name\Downloads\image-converter>
The input images to be appended will be stored in the folder "Append-images", and the output images will be saved to the folder "Appended".
An example of the command I will be using is:
convert +append input.png input.png output.png
So I would need to modify the command to take the input images from \\Append-images and save the output images to \\Append-images\\Appended.
PS I can't use the full "C:\\..."
path as this will be used by different people and the image-convert folder will be saved in different places. So I need the command to build on the "PS C:\\...\\image-converter>"
path that Powershell will be run from.
Use environment variables to get the userprofile, and then your subdirectorys:
$env:userprofile
Will give you your C:\\Users\\User1
If you want to make the folders, do the following:
mkdir $env:userprofile\images
mkdir $env:userprofile\images\AppendImages
mkdir $env:userprofile\images\Output
And then work with those.
How about this.
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
Get-Content -path "$scriptPath\Append-images\"
That should give you the location you need to browse the subsequent files.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.