我想写重命名文件夹,子文件夹中的脚本。 换句话说,该分类将走向:
Directory/Company X/1
Directory/Company X/2
Directory/Company X/3
Directory/Company X/4
Directory/Company X/5
Directory/Company X/6
Directory/Company X/7
Directory/Company X/8
Directory/Company X/9
Directory/Company X/10
Directory/Company X/info
至
Directory/Company X/Project 1_1
Directory/Company X/Project 2_2
Directory/Company X/Project 3_3
etc..
到目前为止,我有:
tell application "Finder"
-- Defining Pro Folders
set pro_folder to folder POSIX file "/Users/Jart/Desktop/test"
set all_pro_folders to every folder of pro_folder
-- Iterate through folders and check if folder name is greater than one character
repeat with x in all_pro_folders
repeat with y in x
-- Convert the folder name to a string and check if that string is longer than one character
set incomingName to folder ((y as alias) as text)
set incomingNameString to name of incomingName
if length of incomingNameString = 1 then
-- Set old name (number) to a new variable
set oldname to folder ((y as alias) as text)
set oldnameString to name of oldname
-- Do it again for the second part
set oldname2 to folder ((y as alias) as text)
set oldnameString2 to name of oldname2
-- Rename here
set name of y to "Project" & " " & oldnameString & "_" & oldnameString
end if
end repeat
end repeat
end tell
然而,该文件夹现在看起来像:
Directory/Company X/3
Directory/Company X/5
Directory/Company X/7
Directory/Company X/9
Directory/Company X/10
Directory/Company X/info
Directory/Company X/Project 1_1
Directory/Company X/Project 2_2
Directory/Company X/Project 4_4
Directory/Company X/Project 6_6
Directory/Company X/Project 8_8
为什么这样做呢? 如何改变这种代码,以便将重命名的所有文件? 如果你愿意,我可以转储活动/回复日志。