Re: newbie needs help batch filenaming
Re: newbie needs help batch filenaming
- Subject: Re: newbie needs help batch filenaming
- From: Ivan Andrus <email@hidden>
- Date: Sat, 22 Feb 2003 16:38:30 -0700
On 2003.02.22 12:17 pm, email@hidden wrote:
>
I'm hoping to find a philanthropists who can help me write an
>
applescript to auto re-name thousands of files according to a
>
corresponding .txt word list.
>
I have 65,000 files, separated into batches of 500. Each batch of 500
>
files is named identically, using the following protocol: "A_01;
A_02;
>
A_03..." and so on. Each .txt list has the same number of words as
>
files in the batch folders. The words in the .txt files are separated
>
by paragraph breaks.
>
I'm using os 9, but can have access to an on X box
>
Can anyone assist me in writing an applescript that will name the
files
>
according to the word list along the same index [eg. A_01 will be
>
re-named with the 1st word in the list, A_02 will be named with the
2nd
>
word in the list.
I wrote a set of scripts that do something very similar to what you
want. They take the comments from one set of files and place them in
the comments of the other files based on the names. With a few
modifications and tested slightly on OS 9:
======================================================================
on open (x)
x to FolderExpand(x)
set txt to choose file
set theNames to read txt
--If you have Jon's Commands OSAX you could alternately
--retrieve the file names by:
--set theCom to the clipboard
if (count x) is not equal to (count (paragraphs of theNames)) then
display dialog ("Putting comments with" & return & tab &
[NO-BREAK]((count (paragraphs of theNames)) as text) & " paragraphs
[NO-BREAK]in the text." & return & tab & (count x) as text) & "
[NO-BREAK]files." & return & "Quantity mismatch. What to do?"
[NO-BREAK]buttons {"Cancel", "Continue"} default button "Continue"
end if
tell application "Finder"
set x to (sort x by name)
--You can tell the finder to sort by
--something else here: mod. date etc.
repeat with i from 1 to count x
set name of (item i of x) to paragraph i of theNames
end repeat
end tell
end open
(*
This is a routine to allow you to drop a single folder and change
the names of the folders contents. I believe the are issues with
"contents of" in some versions of AppleScript. I haven't had any
problems. Perhaps it was with "entire contents of".
*)
on FolderExpand(x)
if (count of items of x) = 1 then
tell application "Finder"
if character -1 of ((first item of x) as text) is ":" then
set x to (contents of folder (x as alias)) --as alias list
end if
end tell
end if
return x
end FolderExpand
======================================================================
[formatted using ScriptToEmail - gentle relief for mailing list pains]
[
http://files.macscripter.net/ScriptBuilders/ScriptTools/ScriptToEmail
.hqx]
Save it as an applet and drop a folder or a list of files on it. It
will prompt you to open a text file with the names. Enjoy. BTW work
on copies the first time, just in case. I don't want to be the
recipient of a reprimand ;-)
HTH
Ivan
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.