Re: Changing File Names
Re: Changing File Names
- Subject: Re: Changing File Names
- From: Luther Fuller <email@hidden>
- Date: Thu, 1 Jun 2006 07:13:49 -0500
On May 31, 2006, at 10:48 PM, Jeff Grossman wrote:
I am moving our AppleshareIP File Server over to a Windows Server.
A lot of
my users files have certain characters (i.e. "/" and "\") in the
file name
which are not valid on a windows machine. Would I be able to write an
applescript that would go through each file on the file server and
change
any of those characters to different ones? If so, can somebody
give me a
hand? I am not great with applescript.
FWIW, Here's what I used ...
on open dropList
tell application "Finder"
repeat with dropItem in dropList
if (class of item dropItem) is folder then
my scanForSlash(dropItem)
end if
end repeat
end tell
end open --------------------
on scanForSlash(folderRef)
tell application "Finder"
select folderRef
set folderName to (name of folderRef) as text
if "/" is in folderName then
set AppleScript's text item delimiters to {"/"}
set nameList to (text items of folderName) as list
set AppleScript's text item delimiters to {"-"}
set folderName to nameList as text
--
beep 2
display dialog "New name" & return & "\"" & folderName & "\""
buttons {"Cancel", "Skip", "OK"} default button 3
if button returned of the result is "OK" then
set contRef to (container of folderRef) as alias
set name of folderRef to folderName
set folderRef to (folder folderName of contRef) as alias
end if
end if
--
open window of folderRef
try
set itemList to (every file of folderRef whose name contains "/")
as alias list
on error
set itemList to {(some file of folderRef) as alias}
end try
try
(every folder of folderRef) as alias list
on error
{(some folder of folderRef) as alias}
end try
set itemList to itemList & the result
repeat with dropItem in itemList
select dropItem
if (class of item dropItem) is folder then
my scanForSlash(dropItem)
else
set itemName to (name of dropItem) as text
if "/" is in itemName then
set AppleScript's text item delimiters to {"/"}
set nameList to (text items of itemName) as list
set AppleScript's text item delimiters to {"-"}
set itemName to nameList as text
--
beep 2
display dialog "New name" & return & "\"" & itemName & "\""
buttons {"Cancel", "Skip", "OK"} default button 3
if button returned of the result is "OK" then
set name of dropItem to itemName
end if
end if
end if
end repeat
try
close window of folderRef
end try
end tell
end scanForSlash -----------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden