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

vloryan

macrumors member
Original poster
Jan 11, 2014
57
0
Hi,

I have an folder full of PDFs (located at "/Users/johndoe/Desktop/xyz") and would like to move any PDF (only one file!) to another folder (located at "/Users/johndoe/Desktop/goal").

Would be great if you could help me here!

Thanks!
 
I'm not sure what you mean by "one file", but this should move all PDFs in that folder.

do shell script "mv ~/Desktop/xyz/*.pdf ~/Desktop/goal/"

If there is just one particular PDF you want to move change the * into the file name.
 
There's a command line that will do it

Code:
mv `ls /Users/johndoe/Desktop/xyz*.pdf | tail -1` /Users/johndoe/Desktop/goal
 
With "one file" I mean one random file out of more than fifty pdfs... thanks!
 
sorry for beeing not very specific. i'd like to know how to move one file only.
 
The command line option I gave is pretty much random and only copies one file. You could mix it up more by changing sort options on the ls command.
 
@JustMartin / That works great as long as the filename does not contain an empty space character. Any ideas how to solve this? Thank you so much!
 
@JustMartin / That works great as long as the filename does not contain an empty space character. Any ideas how to solve this? Thank you so much!

In the command line when there is an empty space you need to use the escape character.

So you would enter...

Code:
shopping list.pdf

as

Code:
shopping\ list.pdf
 
I do not use specific filenames, but "*.pdf" in my command line.
 
try putting a " around the phrase in back ticks

Code:
mv "`ls /Users/johndoe/Desktop/*.pdf | tail -1`" /Users/johndoe/Desktop/goal
 
In the command line when there is an empty space you need to use the escape character.

So you would enter...

Code:
shopping list.pdf

as

Code:
shopping\ list.pdf

You should use
Code:
set myFile to "any file i want.pdf"
set src to "/Users/johndoe/xyz/" & myFile
set src to "/Users/johndoe/goal/" & myFile

do shell script "mv " & (quoted form of src) & " " & (quoted form of trg)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.