2 日前、私は 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 についてもう少し理解できるようになります。
ありがとう!