LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-14-2013, 04:18 AM   #1
unixunderground
LQ Newbie
 
Registered: Sep 2013
Posts: 8

Rep: Reputation: Disabled
Question Move files contained in source dir to destination dir, but not source dir itself


Hello folks,

I am runninng a debian server at a remote location, that I use as a media streaming server with subsonic.

What I want to do, is that I would like to "drag-and-drop" files to my Subsonic server remotely, and in order to do so I am planning to use bittorrent sync + some scheduled cron command that will move the incoming files from the source directory (bittorrent sync folder synced to my local pc) to the media directory on the server (subsonic)

Basically what I need this scheduled script to do, is to move all the contents of a given directory (but not the directory itself) to another directory, at a scheduled time (cron)

I was thinking of using mv but I am not sure wether or not an option is present to only move the contents of the folder, but not the folder itself

Any ideas on how I could do this?

Thanks in advance!
 
Old 09-14-2013, 07:06 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Code:
TMPFILE=`mktemp -p /tmp cron.XXXXXXXXXX` && {
crontab -u $LOGNAME -l > "${TMPFILE}"
echo "# Move files every hour:" >> "${TMPFILE}"
echo "* */1 * * * find /some/path -maxdepth 1 -type f -iname \*.torrent -print0 | xargs -0 -iX mv 'X' /some/other/path" >> "${TMPFILE}"
crontab -u $LOGNAME "${TMPFILE}" && "${TMPFILE}"; }
crontab -u $LOGNAME -l
 
2 members found this post helpful.
Old 09-14-2013, 07:17 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
@ unSpawn: Nice!
 
Old 09-20-2013, 11:17 AM   #4
unixunderground
LQ Newbie
 
Registered: Sep 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by unSpawn View Post
Code:
TMPFILE=`mktemp -p /tmp cron.XXXXXXXXXX` && {
crontab -u $LOGNAME -l > "${TMPFILE}"
echo "# Move files every hour:" >> "${TMPFILE}"
echo "* */1 * * * find /some/path -maxdepth 1 -type f -iname \*.torrent -print0 | xargs -0 -iX mv 'X' /some/other/path" >> "${TMPFILE}"
crontab -u $LOGNAME "${TMPFILE}" && "${TMPFILE}"; }
crontab -u $LOGNAME -l
Wow thank you!

That was a really classy way to go about it.

I got everything working smoothly with your script and the whole thing is just awesome now.

Thanks again!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tar dir and sub dir removing files but not existing not empty dir j-me Linux - General 2 08-12-2013 11:37 AM
include ,h files from dir inside dir knobby67 Programming 1 02-02-2011 06:06 AM
Remove Certain Files/Dir from Large Dir thomas.beaver Linux - Newbie 2 01-27-2008 08:47 AM
Command to display /dir, /dir/sub, /dir/sub/files knockout_artist Linux - Newbie 9 10-25-2007 02:57 PM
Q. moving /bin dir files to /dev dir?? Texas_student Linux - Software 2 03-26-2006 11:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration