I can’t thank people enough for their help with this, I really wasn’t expecting such well written, informative answers to my questions.
Unfortunately I am still struggling with getting this script to work as perfectly as it needs to.
Firstly, I have sorted the whole move/copy issue. The folder where the picture files get dropped (to which the script is attached) is on the same volume as the folders where it is moving the files to, therefore it should have been moving rather than copying all along.
The problem was that I had written the script so that it had the whole path to each folder. I solved this by providing the path to the folders at the top of the script as an alias and then referring to the variable name further down the script.
Let me explain exactly what is happening here.
Basically, a program called Intellitune is picking photo files up from a specific ‘watched’ folder. Intellitune then alters these photos in different ways and then outputs the files when it has finished with them to another folder. The folder to which it outputs is called ‘Intellitune_Processed’. From here, my script needs to move these photos to the correct folder (on the same volume) based on the beginning part of the filename of the files.
My problem is:
It seems that sometimes the script works fully and sometimes not. The script sometimes deals with all the photos properly and they all disappear and go to the correct folders. Other times, the script seems to move most of the files but leaves maybe two or three (out of the twelve or so I am putting in).
At these times, the script doesn’t look like it has errored in any way. There are certainly no error messages on the screen. The script also hasn’t detached itself from the folder. I can prove that the script is still running because If I leave the photos that it seems to have missed out in the folder and add a few more, more often than not the script will deal properly with the new photos and move them to the correct folders.
It made me wonder if the script is tying to move files before the Intellitune program has properly finished writing the file to the folder. Because of this, I tried dropping photos into the folder
manually. Unfortunately the same thing occurs and some files move sometimes, other times all the files will move. When dropping manually, I have tried putting about twelve files in at once and also tried dropping files in one by one.
The script does seem to do better when I drop the files in individually but again will not always move all the files. Please can somebody help me out here!! I have spent a long time today at work trying different things and nothing seems to make the script work perfectly.
I also tried saving the script as a ‘script’ rather than an application and attached that to the folder instead. It still did it’s job of moving files but again failed to move all the files everytime I tried.
The script I have so far is:
property LifestyleIn : "OPI:IN:Lifestyle:" as alias
property PropertyIn : "OPI:IN:Property:" as alias
property GazetteIn : "OPI:IN:Gazette:" as alias
property ErrorIn : "OPI:IN:Misnamed:" as alias
on adding folder items to thisFolder after receiving theFiles
tell application "Finder" to repeat with indvFile in theFiles
set fileName to name of indvFile as text
try
if fileName contains "li-" then
move indvFile to LifestyleIn with replacing
else if fileName contains "pr-" then
move indvFile to PropertyIn with replacing
else if fileName contains "gg-" then
move indvFile to GazetteIn with replacing
else
move indvFile to ErrorIn with replacing
end if
end try
end repeat
end adding folder items to
Please can somebody give me an idea as to what could be causing this problem!
Thank you