Solved

PS 3 to run command line program recursively

Posted on 2014-01-02
2
336 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 39

Accepted Solution

by:
footech earned 250 total points
Comment Utility
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 82

Assisted Solution

by:oBdA
oBdA earned 250 total points
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Synchronize a new Active Directory domain with an existing Office 365 tenant
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now