Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Trying to run some code, but having problems

Featured Replies

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/

  • Author

I guess nobody else knows how to do this. LOL

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

  • Author

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#

 

I think I see the problem.

 

/mnt/disk3/Movies/Handbrake/2do/* should be /mnt/disk3/Movies/HandBrake/2do/* according to your working directory.

  • Author

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.

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.