set thelist to {}
set thefold to "5:what:"
tell application "Finder" to set thefiles to every file in folder thefold
set thecount to the count of thefiles
repeat with i from 1 to thecount
set aitem to item i in thefiles
set thename to name of aitem
set thesize to size of aitem
--set end of thelist to thesize
set aitem to aitem as text
set thepath to quoted form of (POSIX path of aitem)
if thesize is greater than 3997 then
-- set end of thelist to thepath & return & thesize
set thecmd to "split -a 1 -b4000 " & thepath & " " & i
set end of thelist to thecmd
do shell script thecmd
end if
end repeat
--thelist
I have used “thelist” to check the size, the path and even the command. I copied the command shown in the result window to Terminal and executed it and it works. However, this applescript does not work. I get no errors but no files are generated either. It is extremely annoying. What am i doing wrong?
Among the differences between Terminal shells and do shell script shells is the current working directory. See TN2065. For do shell script, it is often “/” (the root of your boot volume), though it might be anything since it is inherited from the process that runs do shell script.
Have you looked in your root folder? If split is working (you did not get an error message), it is probably putting your 1[a-z], 2[a-z], 3[a-z], etc. files in the root folder.
To control where they go you could to cd there as the first part of the do shell script command: do shell script “cd /Volumes/5/what && split .”
Maybe you could do something like this:
.
set thefoldpath to quoted form of POSIX path of thefoldpath
.
set thecmd to "cd " & thefoldpath & " && split -a 1 -b4000 " & thepath & " " & i
.
Alternatively, you could put the path in front of your output prefix:
.
set thefoldpath to quoted form of POSIX path of thefoldpath
.
set thecmd to "split -a 1 -b4000 " & thepath & " " & thefoldpath & i
.
Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari 4.0.2 (4530.19)
Operating System: Mac OS X (10.4)
Yes, I had my eyes on the root folder. Because when I used to copy and paste “thecmd” generated in the results window of Script Editor to the Terminal, the files used to be generated in the root folder. But applescript did not generate the files. I still cannot understand why.
Out of the two alternatives, you suggested the first one does work fine.
Thanks, chrys.