Hello to this wonderful community!
Three more questions. (2 related to this topic, the third kinda of
)
I hope it's okay I didn't open another topic.
1. I saw that in my first question, in order to remove the extension,
penpen wrote "%%~dpna" .
What do I need to write to add the string "-i" characters to the name of the file, without removing the extensions.
So let's say I have the file "D:\folder\file.pdf". I want to apply script below which creates the file "D:\folder\file-i.pdf"
Code: Select all
@echo off
for /r "%cd%" %%a in ("*.pdf" ) do (
magick -density 150 "%%~fa" -compress JPEG [b]"??????"[/b])
goto :eof
2. I want to extract all zip files found in a folder and extract them with Powershell to a folders.
Code: Select all
for /r "%cd%" %%a in ("*.zip") do powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem';
[IO.Compression.ZipFile]::ExtractToDirectory('%%~fa', '00. name of zip file'); }
How can I can I add the string "00." to the name of the zip file to create that specific folder. I've tried lots variations, but I can't find the solution.
3. I have a script which takes all word files (*.doc *docx) from a folder and converts them in PDF files.
I want to call this code from command prompt, without manually entering in PowerShell, like I did in the first question.
Once again, I've tried lots of variations, I just receive errors.
Code: Select all
$path = "c:\test\1" #Target directory for converting Word files
$word_app = New-Object -ComObject Word.Application
#Convert .doc and .docx to .pdf
Get-ChildItem -Path $path -Filter *.doc? | ForEach-Object {
$document = $word_app.Documents.Open($_.FullName)
$pdf_filename = "$($_.DirectoryName)\$($_.BaseName).pdf"
$document.SaveAs([ref] $pdf_filename, [ref] 17)
$document.Close()
}
$word_app.Quit()
P.S. Like I said previous, I hope it's okay I didn't open another topic.