Solved

PS 3 to run command line program recursively

Posted on 2014-01-02
2
339 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
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 83

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
A procedure for exporting installed hotfix details of remote computers using powershell
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

24 Experts available now in Live!

Get 1:1 Help Now