kizer Posted November 11, 2011 Share Posted November 11, 2011 I'm trying to run some code from a script that will more or less copy the 2 oldest files from one directory to another. My intent is to throw a bunch of files into a directory and have my windows machine grab them and do some processing. The reason for the two oldest was something I came up with simply because I want to limit it to two files. LOL Anyways heres what I have, but I'm having issues and wondered if somebody could look at it and tell me what I'm doing wrong. mv `ls -t |tail -1` /mnt/disk3/Movies/HandBrake/test The problem I have is I want to run it from cron by simply droping it in the cron folder for daily, but of course its trying to run what I typed in there for that folder when I want to point it at /mnt/disk3/Movies/Handbrake/2do I tried using the following mv `ls -t /mnt/disk3/Movies/Handbrake/2do/ |tail -1` /mnt/disk3/Movies/HandBrake/test but it gives me a no such file or directory found I can run excluding the location for ls, but its rather important. LOL Can anybody give me a clue to what I'm doing wrong. Simply put I want to move the two oldest files from /mnt/disk3/Movies/Handbrake/test/ to /mnt/disk3/Movies/Handbrake/2do/ Quote Link to comment
kizer Posted November 11, 2011 Author Share Posted November 11, 2011 I guess nobody else knows how to do this. LOL Quote Link to comment
dyrewolfe Posted November 12, 2011 Share Posted November 12, 2011 Could you try: mv `ls -t /mnt/disk3/Movies/Handbrake/2do/* | tail -2` /mnt/disk3/Movies/HandBrake/test Otherwise, perhaps this will work: cd /mnt/disk3/Movies/Handbrake/2do && mv `ls -t | tail -2` /mnt/disk3/Movies/HandBrake/test Quote Link to comment
kizer Posted November 13, 2011 Author Share Posted November 13, 2011 Heres the results from that and thank you for the help at least. root@Tower:/mnt/disk3/Movies/HandBrake/2do# mv `ls -t /mnt/disk3/Movies/Handbrake/2do/* | tail -2` /mnt/disk3/Movies/HandBrake/test /bin/ls: cannot access /mnt/disk3/Movies/Handbrake/2do/*: No such file or directory mv: missing destination file operand after `/mnt/disk3/Movies/HandBrake/test' Try `mv --help' for more information. root@Tower:/mnt/disk3/Movies/HandBrake/2do# cd /mnt/disk3/Movies/Handbrake/2do/ && mv `ls -t | tail -2` /mnt/disk3/Movies/HandBrake/test -bash: cd: /mnt/disk3/Movies/Handbrake/2do/: No such file or directory root@Tower:/mnt/disk3/Movies/HandBrake/2do# Quote Link to comment
dyrewolfe Posted November 13, 2011 Share Posted November 13, 2011 I think I see the problem. /mnt/disk3/Movies/Handbrake/2do/* should be /mnt/disk3/Movies/HandBrake/2do/* according to your working directory. Quote Link to comment
kizer Posted November 13, 2011 Author Share Posted November 13, 2011 Wow it works. LOL Damn I feel aweful stupid now. LOL Thanks for the catch. I don't know why I missed that, but well it works now. cd /mnt/disk3/Movies/HandBrake/2do/ && mv `ls -t | tail -2` /mnt/disk3/Movies/HandBrake/test I think the first time I some how missed the && when I used the cd command myself in a little script. Now I have a million files to encode and my little windows box and a little script on my unRAID machine to make it all go smooth. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.