Okay, I am still very unknowledgeable about Applescript. I wonder if someone can help me or point me in the right direction.
In Photoshop 6 when one saves a file in a format that doesn’t support Channels or Layers Photoshop appends the word “copy” to the file. There is no way around this and Adobe seems unwilling to change this for the people who don’t want this addition. So we are forced to highlight and delete the word “copy” every time and for some of us it’s a hundred times a day.
I was thinking it would be possible to defeat this with a script. What I had in mind was a folder inside the main job folder to which the file could be saved. The script would remove the word “copy” (actually it’s a space, then copy) and then transfer the file up a level to the main folder, whatever it is named.
It’s this last part that has me thrown. I think I could set up the folder to change the name but I am not at all sure how to have it sent up to the main folder. And it’s important that it can do this no matter what the name of the main foilder, though the folder with the script attached can always be named the same (interim or something like that).
Any ideas? This would make a lot of Photoshop users happy, believe me.
Thanks.
I believe this example will help will help:
set x to alias "Codex:Gaming:XML Cards:Adventures:"
tell application "Finder" to set y to container of x
y as alias -- returns alias "Codex:Gaming:XML Cards:" - -one level up in the heirarchy
You may also convert the path to text, then use text item delimiters to remove the last two items. Depending on which version of the OS you’re using, you may have to copy the file to the new location, then delete the old one.
I think I get the idea. What you are saying is that once the name has been changed I would copy the file, like copying from a disk, to the “interim” folder’s container (the main folder) right? Then I’d have to delete the file from the interim folder? Is there an alternative way to move the file that wouldn’t leave a copy behind?
Also assuming that if I did this again with the same file it would overwrite the previous one with the usual prompt asking if I want to replace the file. That’s what I want, but will that prompt mess with the script?
This would be in OS 9.2 but if it could work in other versions, like 8.6 that would be a plus.
Is there an online glossary of Applescript terms somewhere? I think I could use that. Had some books but lent them out.
Thanks.
I believe this example will help will help:
set x to alias "Codex:Gaming:XML Cards:Adventures:"
tell application "Finder" to set y to container of x
y as alias -- returns alias "Codex:Gaming:XML Cards:" - -one level up in the heirarchy
You should try to read the dictionnary of the finder. In the script editor choose “Open a dictionnary”(or similar, i’m using a French Version) from the file menu and just choose the Finder, all the terms that you can use within the finder are listed here.
You can try this to move your file one folder up :
tell application "Finder"
move (myfile) to container of container of myfile
end tell
Thanks. I think that gets me a little closer.
I’m hobbled right now in that I am about 35 miles away from my Mac which is at work. I’m on a Windows machine right now, so I can only try to frame out in my mind what I want to do when I get to the Mac. That’s why I was looking for an online glossary.
You should try to read the dictionnary of the finder. In the script editor choose “Open a dictionnary”(or similar, i’m using a French
: Version) from the file menu and just choose the Finder, all the terms that you can use within the finder are listed here.
You can try this to move your file one folder up
tell application "Finder"
move (myfile) to container of container of myfile
end tell
move: Move object(s) to a new location
move reference -- the object(s) to move
to location reference -- the new location for the object(s)
[replacing boolean] -- Specifies whether or not to replace items in the destination that have the same name as items being moved
as in
tell application "Finder"
move file "[insert full path]" to folder "[another full path]" with replacing
end tell
but if you’re using a folder action script, the path names should already be aliases or file specifications, and the word “file” and the word “folder” won’t be needed.
Applescript isn’t the kind of language that lends itself to an online dictionary. Each application defines its own commands (which can be read with the open dictionary menu option in a script editor). That said, the official website does have pdf guides to the language and I think to the finder that may be useful. There once was a html guide, but my link to it has rotted.
Still struggling with it. Since I always have a three letter file extension I am trying to figure out how to isolate and delete " copy" and leave the extension untouched.
set x to "my file.jpg copy"
set newx to text 1 thru -6 of x
newx -- returns myfile.jpg
set x to "my file copy.jpg"
set y to length of x
set newx to (text 1 thru (y - 9) of x) & (text (y - 3) thru -1 of x)
newx -- returns "my file.jpg"
Thank you. I think with all this information I can figure it out.
set x to "my file.jpg copy"
set newx to text 1 thru -6 of x
newx -- returns myfile.jpg
set x to "my file copy.jpg"
set y to length of x
set newx to (text 1 thru (y - 9) of x) & (text (y - 3) thru -1 of x)
newx -- returns "my file.jpg"