Reputation: 475
I am trying to use automator to rename files based on the folder I select as the input. I want to take the folder name and if 1 of 4 phrases are found in the folder name, 1 of 4 variables would be used. I don't know applescript but I feel this is the way to go base on other languages I know.
Can anyone convert the following concept?
if file name contains "USA" then
var = "US"
elseif file name contains "CAN_FR" then
var = "CAFR"
elseif file name contains "CAN_EN" then
var = "CAEN"
end
Much appreciation to anyone that can help.
Upvotes: 2
Views: 2187
Reputation: 11238
Try:
on run {input, parameters}
tell application "Finder" to set folderName to name of first item of input
if folderName contains "USA" then
set var to "US"
else if folderName contains "CAN_FR" then
set var to "CAFR"
else if folderName contains "CAN_EN" then
set var to "CAEN"
else
set var to "Not Found"
end if
-- insert your code here
return var
end run
Upvotes: 2