?
Solved

Search folders and subfolders and save file as JPG

Posted on 2009-05-06
9
Medium Priority
?
487 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 750 total points
ID: 24314460
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Assisted Solution

by:MrJesse34
MrJesse34 earned 750 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
A short article about problems I had with the new location API and permissions in Marshmallow
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes
Suggested Courses

743 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