Solved

PS 3 to run command line program recursively

Posted on 2014-01-02
2
342 Views
Last Modified: 2014-01-02
Powershell 3 or 4 - Can you show me how this program can be run on a folder that contains many subfolders with subfolders to covert the same filename it finds with a .JPG extension to the same filename with a .PDF extension?

JPEGtoPDF from http://www.compulsivecode.com/project_imagetopdf.aspx

USAGE:
jpegtopdf.exe "PDFFilepath_and_name.PDF" "jpeg_file_path_and_name.JPG"

main folder is c:\storage\
I'm looking to create a copy of the file in PDF format like ilename1.jpg to filename1.pdf.
There are only about 1,000 jpg files out of about 600,000 PDF files in the directory tree.


I figure there must be a simple way in PS to do this.
What do you think?
thanks!
0
Comment
Question by:johnj_01201
2 Comments
 
LVL 40

Accepted Solution

by:
footech earned 250 total points
ID: 39751787
You can try the following:
$search = "c:\storage"
gci $search -filter *.jpg -Recurse | %{
    jpegtopdf.exe "$($_.DirectoryName)\$($_.BaseName).PDF" $_.FullName
}

Open in new window

0
 
LVL 84

Assisted Solution

by:oBdA
oBdA earned 250 total points
ID: 39751838
There's a simple way with the good old command prompt as well (you might have to add the path to the exe file, or "cd" into the directory where the exe is stored):
for /r "C:\storage" %a in (*.jpg) do jpegtopdf.exe "%~dpna.PDF" "%~fa"

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This article will help you understand what HashTables are and how to use them in PowerShell.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question