Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Wowzera

macrumors 6502a
Original poster
Oct 14, 2008
858
28
Brazil
Hello,

Here goes a piece of my code until now:
Code:
display dialog "Please select the two ZIP files"
			set theFonts to choose file with prompt "Please select the two ZIP files:" of type {"ZIP"} with multiple selections allowed
			[color=RED][b]duplicate [COLOR="Blue"]theFonts[/COLOR] to fontFolder with replacing[/color][/b]

The highlighted part is a Finder command to duplicate the files, as you can see. I want to use a do shell script command like this one:

do shell script "mv theFonts ~/Documents"

But as expected, it won't work.
Resuming, is there a way to prompt the user to select files and use the output files on a shell script, by transforming it on a String or something else.

Thanks for reading anyway. :)
 
For the shell line I believe you'll want,

Code:
do shell script "mv " & theFonts & " ~/Documents"
 
For the shell line I believe you'll want,

Code:
do shell script "mv " & theFonts & " ~/Documents"

It does not look to work.
I receive the following output:

error
mv: rename Snow to /Users/Test/Documents/Snow: No such file or directory
mv: rename Leopard:Users:Test:Desktop:Chalet to /Users/Test/Documents/Leopard:Users:Test:Desktop:Chalet: No such file or directory
.
.
.
.
It looks to grab each word and then try to rename :(

Edit:
Ok, I got it working. Question solved and answered.
Thanks.
 
theFonts is returning a list of Finder file aliases and the shell doesn't understand them. You need to turn them into POSIX pathnames.

Something like this should work

Code:
repeat with f in theFonts
set fposix to the quoted form of the POSIX path of f
do shell script "mv " & fposix & " ~/Documents"
end repeat

mt
 
theFonts is returning a list of Finder file aliases and the shell doesn't understand them. You need to turn them into POSIX pathnames.

Something like this should work

Code:
repeat with f in theFonts
set fposix to the quoted form of the POSIX path of f
do shell script "mv " & fposix & " ~/Documents"
end repeat

mt

Hello,
Thank you so much for sharing this elegant script. But, it does not look to work properly.
The file does not gets copied and neither return an error or something else. Anyway, I am using cp instead of mv, I want just to get a copy of the file.
If I do the script in Terminal it looks to work:
fposix return the correct path, so I use the same path fposix return and do the following:

Code:
 cp [i]fposix path[/i] ~/Documents
It works, but on the applescript shell command, no.

Could you help me?
Thanks! :)
 
This works for me:

Code:
display dialog "Please select the two ZIP files"
set theFonts to choose file with prompt "Please select the two ZIP files:" with multiple selections allowed

repeat with f in theFonts
	set fposix to the quoted form of the POSIX path of f
	do shell script "cp " & fposix & " ~/Documents"
end repeat

The "of type {"ZIP"}" doesn't work for me. Possibly that particular variation on choose file has been deprecated.

mt
 
This works for me:

Code:
display dialog "Please select the two ZIP files"
set theFonts to choose file with prompt "Please select the two ZIP files:" with multiple selections allowed

repeat with f in theFonts
	set fposix to the quoted form of the POSIX path of f
	do shell script "cp " & fposix & " ~/Documents"
end repeat

The "of type {"ZIP"}" doesn't work for me. Possibly that particular variation on choose file has been deprecated.

mt

Strange, it works for me (of type {~}). Anyway, I solved the issue, it was my fault, I forget to rename the variable name, everything is correct now,
Thank you so much for providing this elegant code :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.