need a script that will copy based on filename and then move to a network share when
Those that have seen my prevouse posts will know im using sabnzbd instead of a vcr so i can use the resaulting files on my netbook at home or on my projector via mediatomb and a ps3.
now originly i was using an archos and the files were converted (thanks to a lot of help from you guys) it made it easy to see what was new what was old by simply looking at the date modified. no archos means no conversion, so i tried to symlink new files, sadly this is not possible due to sabnzbd doing a post processing script then moving the files to there final resting place. I have hit on a new idea but have no idea where to start so im asking for help again heres what i need it to do 1)in the post processing script search the $1 (the folder in which sabnzbd places that download to be postprocessed is always $1 i normaly start with dir = $1) using a text file of target names (say monk supernatural psych etc) and if the file has any of these in its name it then moves onto 2 2) copys the file (not move) to a holding folder 3) (this would have to be a script run from cronjob...which scares the hell out of me as i have used cronjob twice and had to reinstall ubuntu to fix it the first time!) then every 15 minutes i want it to see if my net book is connected on wifi ( the relevent folder will be shared ) i want the script to move all the files from the holding folder to the shared folder on the netbook forceable problems, 3 could move a file thaat 2 is still copying the netbook could be turned off during the move ok so is what im asking doable? |
ok i have (as always) been googling to learn how to create this script, but i really cant get my head around linuz scripting and in lots of parts i have no idea where to even begin looking.
so far i can think off; Code:
#!/bin/bash then the following script executed by cronjob every 30 minutes Code:
mv /home/mrgreaper/holding/* /network/netbook/work/ oh and /network/netbook/work/ is not the real share as im at work and unable to find out what it would be lol am i on the right track? right syntexs? anyone know a good newbie friendly cron job tutorial or better yet a cronjob gui? |
Quote:
Code:
search="search-spec" 2. Just add some commands at the location of the comment. |
Quote:
and replace # do something here eith cp "$file" /home/mrgreaper/holding/"$file" i think i might need to just stick to having them all copyed, at least at first if i go to the network share via places it shows the network folder address as smb://icklepc/tv%20programs/ not sure how to use that in my mv script ? i tried cd smb://icklepc/tv%20programs/ and it says it cant find it so im guessing its not treated like a folder damn this is getting complicated *****************edit*********** i tried cp smb.conf smb://icklepc/tv%20programs/ and got cp: cannot create regular file `smb://icklepc/tv%20programs/': No such file or directory im really stuck |
A couple of things that may help:
1. a good cron howto: http://www.adminschoice.com/docs/cro...Crontab%20file 2. to deal with unfinished copies etc, try rsync instead of cp. It's a bit more learning, but it's designed to only copy differences, so it'll check the src & tgt dirs and just send the differences. Quicker and easier than trying to track them yourself and means you don't have to copy entire filesets every time. HOWTO: http://www.cyberciti.biz/tips/linux-...rectories.html |
well after a lot of searching i have got a bit closer
first im going to let the post script copy all avis regardles of names to the holding folder and only enable it for certain tasks (no sense over complicating things) now the bit im still having issue with the automaticly moving all files from the holding folder to a folder on my net book, i have so far found a sort of method Code:
cd /home/mrgreaper/holding/ two its only copying not moving problem one i thought i gould fix with masks and the mput but mask * then mput did not work seems wildcards are nto aloud in masks grrrrrr ok a possible solution im about to try (im posting before i try as it takes time to get replys and i want to get this fixed so i can sleep tonight and not wake up in the middle of the night with a bright idea that i try to make work for an hour then go back to bed in failure! (i dont just post and wait for a response) my idea is an adaption of my post processing script and i can already see potential problems but it would serve to move the files Code:
#!/bin/bash 1)it attempting to copy a file while the file is being put in to the holding file so it wouldnt copy all of the file 2) this is a biggie, the share not being available so it doesnt copy the file but it still deletes it. so how do i make it check for the share being in existence before it even trys to copy? *note* the rsync command(application) if i understand the page i read will only copy not move have i got that wrong? |
rsync default is to copy, so you'll still have the originals.
There are delete options avail as you'll read, but I'd skip those for now until you've got a solid method working. |
All times are GMT -5. The time now is 04:54 PM. |