Solved

Search folders and subfolders and save file as JPG

Posted on 2009-05-06
9
483 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

770 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