Solved

Search folders and subfolders and save file as JPG

Posted on 2009-05-06
9
481 Views
Last Modified: 2012-05-06
Hi all,

Just got the assaignment to write a JavaScript the searches through a folder and his subfolders for a PSD file. When it finds one it needs to Save it as a JPG.

Is this possible and how to start with it? Haven't got a clue about JavaScript :( It will be good in VB script too it that is easier...

Grts
0
Comment
Question by:Pit76
  • 5
  • 2
  • 2
9 Comments
 
LVL 41

Expert Comment

by:HonorGod
ID: 24314296
That is going to be difficult, especially using any browser other than IE.
Only IE has ActiveX support that allows, or provides support for fileIO from JavaScript.

Most JavaScript implementations don't want scripts accessing the file system for security reasons.
0
 

Author Comment

by:Pit76
ID: 24314325
Is this possible in C#, to write a small app to perform this.

I guess I need to open a found .PSD file with PhotoShop and then save it as a JPG file.
How would I start with this? How to iterate through a folder and his subfolders?

Grts
0
 
LVL 41

Accepted Solution

by:
HonorGod earned 250 total points
ID: 24314460
0
 
LVL 6

Assisted Solution

by:MrJesse34
MrJesse34 earned 250 total points
ID: 24315377
Its easy, just use the FileInfo and DirectoryInfo objects.  Do foreach statements as well.

Like this:

                    System.IO.DirectoryInfo thisInfo = new System.IO.DirectoryInfo(@"C:\pathname\");
                    foreach (System.IO.FileInfo thisFile in thisInfo.GetFiles())
                    {
                        if (thisFile.Extension.ToUpper() == "PSD")
                        {
                            //DO SOMETHING
                        }
                    }
                   
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 41

Expert Comment

by:HonorGod
ID: 24315635
That's what the multi-part article uses...
0
 
LVL 6

Expert Comment

by:MrJesse34
ID: 24315666
You don't need to open with photoshop, you can just save with a different extension.
0
 

Author Comment

by:Pit76
ID: 24323475
How can I save it with anonther extension? Will the file still work then cos  I tried just to rename it but that doesn't work, thet file can't open as a jpg then.

About the recursive function, does it search a folders su and sub sub folders too?

Never have done anything like this before..

Grts
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 24324122
A recursive function will call itself.

Say you have a directory, and you list the contents.
The contents will be files, and possibly more directories.
The routine used to list a directory contents, can be used recursively to process any directories that are encountered.

Does this make sense?

Sorry, I don't have answers for the other questions.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 24355070
Thanks for the grade & points.

Good luck & have a great day
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bunnyEars challenge 6 64
sumDigits  challenge 7 60
topping3 challenge 14 50
Not needed 13 55
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

705 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

11 Experts available now in Live!

Get 1:1 Help Now