Questions from Newbie
Questions from Newbie
- Subject: Questions from Newbie
- From: Max Salven <email@hidden>
- Date: Wed, 28 Feb 2001 11:27:38 +0000
Hi!
What I'm trying to achieve is the following:
I want to create an applescript which I can drop a folder containing lots of
files and folders with nested files.
Then, for each file, the applescript should:
1. Get the Finder comments of the file (ie what you see in Get Info) into a
variable, item_comments.
2. Delete all but the last 36 characters of item_comments.
3. Delete the last 4 characters of item_comments.
4. Rename the file to item_comments.
The reason why I need to do this, is because I receive a lot of files via
FTP, but the filenames are always truncated so that it's only the first 32
characters of the file name. Quite a few of the files I use are named, eg,
as follows:
"File Created by Max Salven - 28-2-01 - Design Demo Outline for Project.txt"
If there are, say, 500 of these similarly named files that I need to
download, all I end up with on my HD is:
"File Created by Max Salven - .0"
"File Created by Max Salven - .1"
"File Created by Max Salven - .2"
...
"File Created by Max Salven - .500"
However, the Finder Comments contain the full name (and FTP path) of the
file.
Hence I'd like to drag and drop a folder of these files onto the
applescript, and they are all automatically renamed to:
" Design Demo Outline for Project"
"1 - Design Demo Outline for Game"
"Design Demo Outline for Displays"
Etc.
Sadly, I know nothing about Applescript.
So far, this is all that I could come up with, and it doesn't work:
----
on open this_item
tell application "Finder"
activate
set the item_comments to the comment of this_item
-- if the item_comments is not "" then [parse the comments]
if the item_comments is not "" then set name of this_item to
item_comments
end tell
end open
----
The error I get is:
"Can't get comment of: {alias "System: Desktop Folder: File Created by Max
Salven - .0"}."
Any ideas on how to fix this?
Also, I'd appreciate tips on how to parse the "item_comments" properly. All
I want it to do is take the right 36 characters, and then the left 32
characters. In VBScript (ugh) it would be something as simple as this:
item_comments = left(right(item_comments,36),32)
But how do I do it in apple script?
Any help and suggestions are very welcome!
Thanks in advance for taking time to help out this newbie!
Regards,
Max Salven