Help with blobbing

 
Thread Tools Search this Thread
Operating Systems OS X (Apple) Help with blobbing
# 1  
Old 09-04-2013
Apple Help with blobbing

I am pretty new to scripting and i was wondering if anyone could help me out.

Here is the situation. I am trying to make an action folder that when an image is saved to it, the image is automatically moved to a folder based upon the first 4 or 5 integers of the name.

image names come in a few variations for example:

1000.jpg
10000.jpg
10000-v1.jpg
10000-v1 copy.jpg

any of the first 4 or 5 integers can be from 0-9.

this is the code i came up with so far.

Code:
tell application "Finder"

   do shell script " if [ -f ~/Desktop/filing/1[0-9][0-9][0-9][!0-9]*.jpg ]
then
scp ~/Desktop/filing/1[0-9][0-9][0-9][!0-9]*.jpg ~/Desktop/filed/1000/
fi"
   
   do shell script "if [ -f ~/Desktop/filing/1[0-9][0-9][0-9][0-9][!0-9]*.jpg ]
then
scp ~/Desktop/filing/1[0-9][0-9][0-9][0-9][!0-9]*.jpg ~/Desktop/filed/13000/
fi"

end tell

the trouble with this code is the wildcard [!0-9] wont work if the image is just 1000.jpg or 10000.jpg as having the [!0-9] means that it is excluding 0-9 range but expecting a character of some sort.

Anyway if anyone could shed some light on a solution to this that would be great.

Kai
# 2  
Old 09-08-2013
Could you re frame your the problem your trying to solve, by stating exactly what you want the script to do? be more specific?


if the photo has this name do this...
if the folder meets this condition do this..
ect.
# 3  
Old 09-08-2013
Perhaps something this is more what you are looking for:

Code:
cd ~/Desktop/filing/
while : 
do
  for i in *.jpg
  do
    if [ -f "$i" ]; then
      case $i in 
         1[0-9][0-9][0-9][!0-9]*.jpg|1[0-9][0-9][0-9].jpg) 
            scp "$i" ../filed/1000 ;;
         1[0-9][0-9][0-9][0-9][!0-9]*.jpg|1[0-9][0-9][0-9][0-9].jpg)
            scp "$i" ../filed/13000 ;;
       esac
     fi
  done
  sleep 10
done

Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question