I am trying to write a script that has to copy a directory from A to B and after succes delete it from A
I’m using usr/bin/find and cp (or mv?) because it’s faster.
When using mv I get an error after the move “Directory cannot be fond”
When using cp nothing happens.
Anyone any ideas?
property archivedir : "/Volumes/Archief/DTP/test"
property parentdir : "/Volumes/DTP/Leenbakker/orders"
set chosenfile to (choose file)
set filecont to read chosenfile
set foldername to paragraphs of filecont
do shell script ("/usr/bin/find " & quoted form of parentdir & " -name " & foldername & "*" & " -type d -exec mv {} " & quoted form of archivedir & " \\;")
mv works, the complete directory is being moved to the destination
If I put the do shell script part between try and end try the error msg is gone
I guess because its a move the find part failes
However, I think copy (cp) and a remove (rmdir) is a better solution
Simply replacing mv by cp doesn’t work - nothing happens
This part I don’t understand
This works without generating the error:
property archivedir : "/Volumes/Archief/DTP/test"
property parentdir : "/Volumes/DTP/Leenbakker/orders"
set chosenfile to (choose file)
set filecont to read chosenfile
set foldername to paragraphs of filecont
try
do shell script ("/usr/bin/find " & quoted form of parentdir & " -name " & foldername & "*" & " -type d -exec mv {} " & quoted form of archivedir & " \\;")
end try
Thats because you don’t have an error handler. Once in a try loop i dont think anything will throw an error unless you add an error handler to the try block.
Like so
try
--codeherererererere
on error
--error handling here
end try