Shell Script to move files

I am looking for help with a shell script(never done one) to move files from a OSX hard drive to a Mounted volume of a SNAP server

My whole purpose is to avoid copying the ._ (dot underscore) files

camelot gave me some direction but i am messing up entering the path somehow cause this code will not check out

do shell script "cd /path/to/Move to Enlarged/; mv * /WEBTEAM/images/Products/Enlarged/"

Thanks in advance for any direction or alternate solutions

-jb :smiley:

You did change the relevant paths to reflect where your files are, right?

cd /path/to/Moved to Enlarged

assumes the source files are in a folder called 'Moved to Enlarged" inside a folder called “to” which is in a folder called “path” on the startup disk.

Since no one else knows exactly where your source files are, you need to adjust the script to your own needs.

cd /Macintosh HD1/Users/jbradfield/Desktop/Move to Thumbnail/

will not compile “unknown Token” it doesnt seem to recognize the forward slash in front of the spaces

I tried removing the spaces by renaming my HD etc and removing the slashes and it compiles but wont move the files

any ideas I am sorry i have never ran shell scripts before
do i have to enable something for them to run?

Does this work?

set posixPath to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:Desktop:Move to Thumbnail"
set shellCommand to "cd " & posixPath
do shell script shellCommand

Doies this work ? – Yes & no

I plan to move the files to a mounted volume of a SNAP server called WEBTEAM

do shell script shellCommand & "; mv * /WEBTEAM/images/Products/ThumbNail/"

that gives me an error

Sorry, I’m not familiar with mv and I don’t have enough experience to string commands together. :frowning:

i got the mv code from camelot hopefully he will see where we are at and help me out

set posixPath to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:"
set posix1 to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:Desktop:Move to ThumbNail"

set Dest to quoted form of POSIX path of "WEBTEAM:Images:Products:ThumbNail:"
set shellCommand to "cd " & posixPath
set shellcom to "cd" & posix1
do shell script shellCommand & "; mv " & posix1 & " " & Dest


this moves stuff but to the wrong place

ugh gotta go home now
deal with this tomorow

set posix1 to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:Desktop:test folder:images:"

set Dest to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:desktop:" 

do shell script "mv " & posix1 & " " & Dest

this will move the whole folder but i need it to move only the files how do i do it?

This might be close to what you need.

Untested and uncompiled:

tell application "Finder" to set filesToMove to (every file of alias "Macintosh HD1:Users:jbradfield:Desktop:test folder:images:") as alias list
set Dest to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:desktop:"

repeat with thisFile in filesToMove
set posix1 to quoted form of POSIX path of thisFile
do shell script "mv " & posix1 & " " & Des
end repeat

If it works at all, I don’t know how it might handle situations where the destination folder already contains a file with the same name as a file which is being moved.

The error in this is that there is no /WEBTEAM at the top level (in /). Mounted disks are in /Volumes, so your line should be

do shell script shellCommand & "; mv * /Volumes/WEBTEAM/images/Products/ThumbNail/"

thanks but i forgot to post that i had it fixed

here is the final script for those interested
any sugestions would be appreciated


tell application "Finder"
	activate
	set buttonResult to display dialog "Do you want to mount server volumes?" buttons {"Yes", "Already Mounted", "Cancel"} default button 1
	if button returned of buttonResult is "Yes" then
		mount volume "smb://jbradfield:first@10.0.0.15/webteam"
		mount volume "afp:/at/SNAP2:*"
		--select file "startup script applet" of folder "bookmarks" of startup disk
		--open selection
		--display dialog "You chose the "yes" button" giving up after 2
	else if button returned of buttonResult is "Already Mounted" then
		--display dialog "You chose the "Already Mounted" button" giving up after 1
	else if button returned of the buttonResult is "Cancel" then
		error number -128
	end if
	set naiislist to list folder "Macintosh HD1:Users:jbradfield:Desktop:Move to Enlarged:" without invisibles
	set graphlist to list folder "Macintosh HD1:Users:jbradfield:Desktop:Move to Graphics:" without invisibles
end tell
--============ Source Files =====================
set posixPath to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:desktop:"
set Thumb to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:Desktop:Move to Thumbnail:"
set enlarged to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:Desktop:Move to Enlarged:"
set graph to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:Desktop:Move to Graphics:"
set test to quoted form of POSIX path of "Macintosh HD1:Users:jbradfield:Desktop:test folder:"


--============ Destinations =====================
set T_Dest to quoted form of POSIX path of "WEBTEAM:Images:Products:ThumbNail:"
set E_dest to quoted form of POSIX path of "WEBTEAM:Images:Products:Enlarged:"
set G_dest to quoted form of POSIX path of "graphics: ARCHIVE:Images:Catalog Number:"

--===========Shell scripts ======================
do shell script "mv " & Thumb & "* " & T_Dest -->this one works
do shell script "mv " & enlarged & "* " & E_dest -->this one works
if graphlist is not equal to {} then
	do shell script "mv " & graph & "* " & G_dest -->this one works
end if


--=================================================
-->Send e mail to Robin <--
--=================================================
try
	set out_filename to ((path to desktop folder) as string) & "the_list"
	set out_file_id to open for access out_filename with write permission
on error
	set the clipboard to naiislist
	tell application "Microsoft Outlook" to CreateMail Body ("Please highlight this and paste the clipboard") Recipients "rdriscoll@chemicon.com" Subject (((number of items in naiislist)) & " New Images on NAIIS") as string with Display
	--display dialog "could not open file for writing"
end try
repeat with i from 1 to count of items of naiislist
	write (item i of naiislist) & return to out_file_id as string
end repeat

tell application "Microsoft Outlook"
	--activate
	CreateMail Body (read file out_filename) Recipients "rdriscoll@chemicon.com" Subject (((number of items in naiislist)) & " New Images on NAIIS") as string without Display
end tell

close access out_file_id
tell application "Finder" to delete file out_filename --"Macintosh HD1:Users:jbradfield:Desktop:da_list"