![]() |
![]() OCAU News - Wiki - QuickLinks - Pix - Sponsors |
|
|||||||
| Notices |
|
Sign up for a free OCAU account and this ad will go away! Search our forums with Google: |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Member
Join Date: Aug 2009
Location: Omicron Persei 8
Posts: 110
|
ok I have tried searching google and couldn't find anything helpful so I'm gonna try the hive mind
I'm looking for a script to check a folder for .rar files and if it finds the files to execute a script (or vis versa doesn't really matter) I thought that this script below would work but for some reason the "$?" returns "0" if it finds a .rar file or not, there may just be something wrong with the script or I might have just made a mistake somewhere and I just can't see it. Any help or input is helpful and I'm more than happy to through this script out if there is a better option available. Code:
for filename in *.rar do find $2 -name '*.rar' if [ "$?" -ne '*.rar' ] then echo norar >> $2/.error else #run the script fi done exit 0
__________________
I AM ROOT HEAR ME RAWR My Rig: AMD Phenom II X4 955 @ 3.2| 8.0GB 1066 DDR2| GA-MA790X-UD4P motherboard|HDDs 500gb raid 1 OS Drive, 1tb Movies, 1tb TV shows, 500gb Downloads, 1tb Games|Gigabyte 5850OC|1 24" Main Screen and 1 24" secondaryMy on and off again blog tristan-dawson.com.au |
|
|
|
| Join OCAU to remove this ad! |
|
|
#2 |
|
Whammy!
Join Date: May 2003
Location: Melbourne
Posts: 3,944
|
find $directory_to_look_in -name -'*.rar' -exec "$script_to_execute" {}\;
Dont' understand why you need a script for this.
__________________
Administrator: Apple Desktop Hardware/Software, Graphics and Programming, Digital Art, iOS Devices, For Sale (PC and Non-PC), Price Check and What/Where Should I Buy? mercury: 11" Macbook Air, i5, 4Gb RAM, 128Gb SSD lunchbox: Mac mini, i5 Dual Core, 4Gb RAM, 500Gb HDD |
|
|
|
|
|
#3 | |
|
Member
Join Date: Aug 2009
Location: Omicron Persei 8
Posts: 110
|
Quote:
But thanks for the idea anyway
__________________
I AM ROOT HEAR ME RAWR My Rig: AMD Phenom II X4 955 @ 3.2| 8.0GB 1066 DDR2| GA-MA790X-UD4P motherboard|HDDs 500gb raid 1 OS Drive, 1tb Movies, 1tb TV shows, 500gb Downloads, 1tb Games|Gigabyte 5850OC|1 24" Main Screen and 1 24" secondaryMy on and off again blog tristan-dawson.com.au |
|
|
|
|
|
|
#4 | |
|
Member
Join Date: Oct 2009
Posts: 1,192
|
Quote:
http://linuxcommand.org/wss0150.php
__________________
Microsoft gives you windows, linux gives you the whole house Last edited by tr3nton; 24th April 2012 at 10:40 AM. |
|
|
|
|
|
|
#5 |
|
Whammy!
Join Date: May 2003
Location: Melbourne
Posts: 3,944
|
Describe what you want to do a bit more - I am still convinced that unless it's enormously complex, you can do it in a one liner.
__________________
Administrator: Apple Desktop Hardware/Software, Graphics and Programming, Digital Art, iOS Devices, For Sale (PC and Non-PC), Price Check and What/Where Should I Buy? mercury: 11" Macbook Air, i5, 4Gb RAM, 128Gb SSD lunchbox: Mac mini, i5 Dual Core, 4Gb RAM, 500Gb HDD |
|
|
|
![]() |
| Bookmarks |
|
Sign up for a free OCAU account and this ad will go away! |
| Thread Tools | |
|
|