Solved

PS 3 to run command line program recursively

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
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 …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

809 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