Re: Newbe- Rename file names
Re: Newbe- Rename file names
- Subject: Re: Newbe- Rename file names
- From: Goksel KAHRAMAN <email@hidden>
- Date: Fri, 26 Jul 2002 10:42:20 +1000
I hope this helps
Kind regards
Sel
Goksel (Sel) KAHRAMAN
Hands On IT Consultancy
14 Willis St. Richmond 3121
Victoria Australia
Tel: 613 9429 8887 Fax: 613 9429 8687
Mob.: 0403 497 876
e-mail: email@hidden
*****************************************************************
on open (myFileOrFolder)
global eachFile
global aspectRatio
global fileName
global caption
--set myFileOrFolder to (choose folder with prompt "Select the Source
Folder")
tell application "Finder"
set myFileOrFolder to myFileOrFolder as alias
set myFileOrFolderContents to contents of myFileOrFolder
set fileCounter to 0
-- **************************************************************
--Start looping through the files
-- **************************************************************
-- it needs to be a multi file search if the dates are the same:
otherwise there are identical file names
-- replace for multi folder
set multipleFolders to false
repeat with currentFolder in every folder in myFileOrFolderContents
-- set currentFolder to myFileOrFolderContents -- take out for
multiple searches
set multipleFolders to true
repeat with eachFile in every file in currentFolder
set fileCounter to fileCounter + 1
set currentFileName to name of eachFile as string
set currentFileAlias to eachFile as alias
--set currentFileType to file type of eachFile as string
set currentFileType to "jpg"
set theCreateDate to the creation date of currentFileAlias
-- as string
set theCreateDateDate to theCreateDate as date
set theDay to the day of theCreateDateDate
set theMonth to the month of theCreateDateDate as string
set theYear to the year of theCreateDateDate
-- make month into numeric value
set monthArray to {"January", "February", "March", "April",
"May", ,
"June", "July", "August", "September", "October",
"November", "December"}
set monthNumberAray to {"1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12"}
set itemnumber to 0
repeat with myMonth in monthArray --look for the keywords
set itemnumber to itemnumber + 1 --matches keywords with
folder
if myMonth contains theMonth then
set theMonth to item itemnumber of monthNumberAray
exit repeat
end if
end repeat
-- end month changing
set theCreateDateString to theYear & "_" & theMonth & "_" &
theDay & "_" & fileCounter
set newfileName to theCreateDateString & "." &
currentFileType as string
-- if kind of myFileOrFolder is not "folder" then
set the name of currentFileAlias to newfileName
end repeat
-- replace for multi folder
end repeat
-- handles all files in source folder
repeat with eachFile in every file in myFileOrFolder
set fileCounter to fileCounter + 1
set currentFileName to name of eachFile as string
set currentFileAlias to eachFile as alias
--set currentFileType to file type of eachFile as string
set currentFileType to "jpg"
set theCreateDate to the creation date of currentFileAlias -- as
string
set theCreateDateDate to theCreateDate as date
set theDay to the day of theCreateDateDate
set theMonth to the month of theCreateDateDate as string
set theYear to the year of theCreateDateDate
-- make month into numeric value
set monthArray to {"January", "February", "March", "April",
"May", ,
"June", "July", "August", "September", "October",
"November", "December"}
set monthNumberAray to {"1", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "11", "12"}
set itemnumber to 0
repeat with myMonth in monthArray --look for the keywords
set itemnumber to itemnumber + 1 --matches keywords with
folder
if myMonth contains theMonth then
set theMonth to item itemnumber of monthNumberAray
exit repeat
end if
end repeat
-- end month changing
set theCreateDateString to theYear & "_" & theMonth & "_" &
theDay & "_" & fileCounter
set newfileName to theCreateDateString & "." & currentFileType
as string
-- if kind of myFileOrFolder is not "folder" then
set the name of currentFileAlias to newfileName
end repeat
end tell
end open
_______________________________________________
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.