-
1. Re: Save All Open Files
c.pfaffenbichler Aug 8, 2013 7:43 AM (in response to bonalymac999)I’m not sure I understand what you mean by »the initial save to the source directory«.
Do you mean the line
if (theDoc.saved == false) {theDoc.save()}
does not work?
That is only intended to apply to files that have been saved and therefore have a path already.
The split files have no path yet and as far as I can tell no immediate connection to the files they were »cropped and straightened« from.
But one could, I guess, deduce the file/s they originated from by their names and then use the path of the file that has the same name (save for the »copy« and numbers).
-
2. Re: Save All Open Files
Michael L Hale Aug 8, 2013 7:58 AM (in response to bonalymac999)I think the problem is you are mixing how you spec the path, even on Windows I would use the following ( otherwise you end up with E:\Split/someDocName.jpg )
var docPath = '/E/Split';
If you really want to use the Windows style for the path do this instead
var docPath = new Folder('E:\\Split');
But the bigger problem may be the Split folder doesn't exists. I would add a line to make sure E:Split is an existing folder ( if it doesn't exists the save will fail )
if(!docPath.exists) docPath.create();
Finally, one of the save is in a catch block. Are you sure that the save in that block is ever called?
-
3. Re: Save All Open Files
Michael L Hale Aug 8, 2013 8:10 AM (in response to Michael L Hale)Thanks to c.pfaffenbichler I just noticed the line
if(theDoc.saved==false) theDoc.save();
That line will only save if the doc has been changed since it was opened. Could it be you want to save a doc that hasn't been changed like the doc you ran Crop and Straighten on?
-
4. Re: Save All Open Files
bonalymac999 Aug 8, 2013 8:29 AM (in response to c.pfaffenbichler)Firstly thanks for the help. It is appreciated.
My apologies. I'm fogetting that they do not have a path yet.
My original thought had been to try and get the script to save the cropped/straightened fiiles into the same directory as the file they originated from. So no worries, it works as it is
-
5. Re: Save All Open Files
bonalymac999 Aug 8, 2013 8:29 AM (in response to Michael L Hale)Michael
Firstly thanks for the help. It is appreciated.
I have to say I do not know if the save is ever called, but the script as a whole seems to work.
I will add the check you suggest on the existence of the folder. I had added it today, to make sure it exists. but the check will help.
Thanks again
-
6. Re: Save All Open Files
c.pfaffenbichler Aug 8, 2013 8:31 AM (in response to bonalymac999)The only way I can think of to determine the »originator«-file and thus its path is the name-similarity.
I suppose one could run through app.files with a for-clause and compare the names.
-
7. Re: Save All Open Files
c.pfaffenbichler Aug 8, 2013 8:32 AM (in response to bonalymac999)You are a bit generous with your ratings of the posts.
I guess you are being polite, but I think the »correct« ranking is premature.
-
8. Re: Save All Open Files
Michael L Hale Aug 8, 2013 8:53 AM (in response to c.pfaffenbichler)c.pfaffenbichler wrote:
The only way I can think of to determine the »originator«-file and thus its path is the name-similarity.
I suppose one could run through app.files with a for-clause and compare the names.
It's hard to tell without seeing the full script but if it is opening the files one at a time to run Crop and Straighten and saving the open documents created then app.documents[0] would be the 'source' file and you could base the new names off of that document name.
-
9. Re: Save All Open Files
c.pfaffenbichler Aug 8, 2013 8:54 AM (in response to Michael L Hale)You are right; I had assumed that the Script is run after using »Crop&…« but that is not necessarily the case indeed.
-
10. Re: Save All Open Files
bonalymac999 Aug 8, 2013 9:51 AM (in response to c.pfaffenbichler)I am not a massive user of these forums, so I am not as well versed in the etiquette as regular users.
But as far as I am concerned, you have/had solved the issue for me. The script already worked as it was posted, all I was trying to do was tinker with it. I'm a complete beginner - I think I've only written about three scripts in the last few years. I do like to learn when I can, and whilst I can't cope with starting from scratch, I find that I I find a similar script I can usually adapt it to suit my needs. That and Google and forums when stuck let me do the minimal amout of scripting I need. I have self-taught to learn to use vba for Office in the same way although I do use it more than scripting here.
In this case I'd be wasting your and my time trying to go further. I am scanning in hundreds of old photos, and while it is time consuming, it is a one-off job, so I am happy that maybe I do have to do a bit of manual file movin before or after the action/script. I am able to run an action to trim my images to 99%. Follow that with this action which crops/straightens then invokes this script to save the documents. The net result is a huge time saving.
So thanks very much for your input, you did really answer my question.
Help from forums is often under-appreciated. I like to research first before asking questions (that's how I found these scripts from 2011!). I will never learn if all I do is rush to a forum with every question when I'm stuck. So when I get help, I do like to say thanks properly.
The ability to get help from people like you is a great help to beginners like me, and really is appreciated.
Colin


