Solved

Search folders and subfolders and save file as JPG

Posted on 2009-05-06
9
486 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
[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
  • 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
In this post we will learn different types of Android Layout and some basics of an Android App.
Introduction to Processes
Starting up a Project

707 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