It is currently Fri Oct 28, 2016 1:44 pm

sync content only when content

All times are UTC - 6 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Tue Jul 19, 2016 4:18 am   

Joined: Tue Jul 19, 2016 4:13 am
Posts: 1
I'm fairly new to the script scene, but done quite a bit of progress.
I've been trying to create the following script:

# mount drive
# check if files in source directory
# if no files exist in source directory, do nothing
# if files in source directory, check if destination directory exists
# if destination directory exists, don't create destination directory
# if destination directory doesn't, create destination directory
# if files exist and destination directory exists, copy files from source directory
# once all files from source directory have been copied to d-directory, delete files in s-directory

what I cam up with so far:
###############if no dir create dir and if files copy files

if ((test -s "$file") & (-d $directory_name))
echo "Directory already existing"

mkdir $directory_name

#copy files

find A/ -name "*.mp3" -type f -print0 | xargs -0 -I '{}' /usr/bin/rsync -av "{}" inbound/
echo "*********copying files"


#ask to delete files in transfer folder

but I am lost in this, as I have to connect several if statements.

 PostPosted: Wed Jul 20, 2016 3:01 pm   

Joined: Mon Oct 20, 2014 9:53 am
Posts: 500
Please use code tags, if posting code.
This is unreadable.

There is no such test command like ( )
Either use [ ] which is often is just a link to the test command
or use [[ ]] .
Double brackets is the syntax for the internal Bash construct.
Read about it with help "[["
Read about the posix compatible test commands with man test or man "[".

And finally there is no need to test whether a directory exist.
Just use mkdir -p /some/deeply/nested/directory This will create the entire path for you and does not complain on already existing parts or the complete path.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours

Who is online

Users browsing this forum: No registered users and 7 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group