两天前我学到了一点关于applescripting的知识——这是我第一次“编程”,所以你可能会看到一些有趣的东西:
tell application "Finder"
--I don't really know why I use as string but otherwise it won't work
set strFilepath to selection as string
set mainFolder to strFilepath
if (exists strFilepath & "ro") is false then
make new folder at mainFolder with properties {name:"ro"}
make new folder at mainFolder & "ro" with properties {name:"carta"}
make new folder at mainFolder & "ro" with properties {name:"A4"}
end if
if (exists strFilepath & "ingl") is false then
make new folder at mainFolder with properties {name:"ingl"}
make new folder at mainFolder & "ingl" with properties {name:"carta"}
make new folder at mainFolder & "ingl" with properties {name:"A4"}
end if
if (exists strFilepath & "es") is false then
make new folder at mainFolder with properties {name:"es"}
make new folder at mainFolder & "es" with properties {name:"carta"}
make new folder at mainFolder & "es" with properties {name:"A4"}
end if
if (exists strFilepath & "it") is false then
make new folder at mainFolder with properties {name:"it"}
make new folder at mainFolder & "it" with properties {name:"carta"}
make new folder at mainFolder & "it" with properties {name:"A4"}
end if
if (exists strFilepath & "fr") is false then
make new folder at mainFolder with properties {name:"fr"}
make new folder at mainFolder & "fr" with properties {name:"carta"}
make new folder at mainFolder & "fr" with properties {name:"A4"}
end if
if (exists strFilepath & "port") is false then
make new folder at mainFolder with properties {name:"port"}
make new folder at mainFolder & "port" with properties {name:"carta"}
make new folder at mainFolder & "port" with properties {name:"A4"}
end if
--it does what I want up until here
set allFiles to entire contents of mainFolder
--here I get an error nummber -1728, I guess because of that string...
try
--I guess this code also doesn't work… I have PDF files that end like xxx_it_carta.pdf, xxx_it_A4.pdf, xxx_en_carta.pdf, etc
search of (name of every item of allFiles) for "_it_carta"
if file exists then move to mainFolder & "it" & "carta"
end try
search of (name of every item of allFiles) for "_it_A4"
try
if file exists then move to mainFolder & "it" & "A4"
end try
--and so on
end tell
请帮我安排这段代码,这样我就可以正常工作了,我会更多地了解applescript。
谢谢!