Sponsored Content
Full Discussion: Help with blobbing
Operating Systems OS X (Apple) Help with blobbing Post 302850243 by kailasgurung on Wednesday 4th of September 2013 10:29:45 AM
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
 
MRENAME(1)						      General Commands Manual							MRENAME(1)

NAME
mrename - program to rename files SYNOPSIS
mrename 'pattern' prefix [option] DESCRIPTION
This manual page documents briefly the mrename command. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. mrename is a tool for easy and automatic renaming of many files. The 'pattern' is the pattern to search files to rename (quoted to avoid that bash resolve it), and prefix is the prefix that will be added to the name of each file. The two alternative options for copying or moving files in the new name are explained below. All parameters are needed, and you have to stay and launch the script in the same direc- tory of the files to be renamed. The program should be able to write in this directory. OPTIONS
There are only the following three options. -c The option -c will copy each file with the new filename. -m The option -m will move each file in the new filename. -h Display help. EXAMPLE
If you have a directory with two jpeg images prof.jpg and forp.jpg and you want to add them a prefix like item0, item1 etc.. (that is item0prof.jpg, item1forp.jpg etc..) do this: cd /path/to/the/images mrename '*.jpg' item -c to copy each matching file into another with the new name mrename '*.jpg' item -m to rename each file without keeping a copy with the previous name Word-Wide-Web: http://alfalinux.sourceforge.net/mrename.php3 AUTHOR
: Giancarlo -rofus- Erra e-mail: rofus@mindless.com This manual page was written by Dr. Guenter Bechly <gbechly@debian.org>, for the Debian GNU/Linux system (but may be used by others). It is distributed under the GPL just like mrename itself. October 22, 2000 MRENAME(1)
All times are GMT -4. The time now is 06:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy