PDA

View Full Version : Applescript to move all .mp4 & .m4v from dropbox




dglenn9000
May 30, 2013, 11:42 PM
I am looking for an Applescript to move all .mp4 & .m4v from my dropbox folder to my itunes media folder. Any suggestions?



kryten2
May 31, 2013, 12:59 PM
I would suggest you take a look at Automator to do this.

Edit : If dropbox folder is on indexed drive then mdfind is fast. But like subsonix said if you want iTunes to be aware of them you need to import them.

mdfind -0 -onlyin ~/Dropbox/ "(kMDItemFSName = "*.mp4" || kMDItemFSName = "*.m4v")" | xargs -0 ...

sero
Jun 1, 2013, 04:24 PM
one liner in terminal

for i in $(find ~/Dropbox -name "*.mp4"); do mv $i itunes_folder; done

chown33
Jun 1, 2013, 04:44 PM
one liner in terminal

for i in $(find ~/Dropbox -name "*.mp4"); do mv $i itunes_folder; done

The red-hilited part can be replaced with:
for i in ~/Dropbox/*.mp4
Shell pattern-matching (globbing (http://en.wikipedia.org/wiki/Glob_(programming))) suffices.

FWIW, the posted code won't work if there are spaces embedded in any filename. The problem exists for both approachs ('find' or globbing).

subsonix
Jun 1, 2013, 05:41 PM
one liner in terminal

for i in $(find ~/Dropbox -name "*.mp4"); do mv $i itunes_folder; done

I don't think it's enough to just move the files, if you want iTunes to be aware of them you need to import them. There is an "import to iTunes" action available in Automator though, and it's also available by default in the context menu on OS X if you select a media file.

sero
Jun 3, 2013, 12:35 AM
The red-hilited part can be replaced with:
for i in ~/Dropbox/*.mp4

I was assuming the files are not all in the top level dir, otherwise this would be easy enough in finder. But the OP didn't really specify.