Solved

PS 3 to run command line program recursively

Posted on 2014-01-02
2
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 85

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

615 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