+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
Scripts Thread, simple bash for loop script in Coding and Web Development; just booting linux box at the mo, but AWK should do what you want. try Code: find $folder -name 'ntuser.dat' ...
  1. #16
    box_l's Avatar
    Join Date
    May 2007
    Location
    Herefordshire
    Posts
    436
    Thank Post
    77
    Thanked 94 Times in 78 Posts
    Rep Power
    63
    just booting linux box at the mo, but AWK should do what you want.

    try

    Code:
    find $folder -name 'ntuser.dat'  -ls | awk '{printf $8 ":" $9"\n"}'
    also stat

    Code:
    stat -c %y ntuser.dat   | awk '{ printf $1 "\n"}'

  2. 2 Thanks to box_l:

    srochford (5th August 2009), webman (4th August 2009)

  3. #17

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,866
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    No need to fork anything:

    Code:
    find . -type f -name "ntuser.dat" -mtime +90

  4. Thanks to powdarrmonkey from:

    srochford (5th August 2009)

  5. #18

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,531
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Quote Originally Posted by powdarrmonkey View Post
    You don't need a for loop, find will do it without bashims:

    Code:
    find . -type f -name "*.avi" -o -name "*.mkv" -exec mencoder "{}" -oac lavc -ovc lavc -of lavf -lavcopts aglobal=1:vglobal=1:vcodec=mpeg4:vbitrate=2500:acodec=libfaac -af lavcresample=48000 -vf scale=432:240,harddup -lavfopts format=psp -ofps 30000/1001 -o "{}.mp4" \;
    Thanks for that, but it doesnt seem to be working...

    Code:
    robert@rubuntu:/media/disk/woking$ ls
    convert.sh                                          The.Shield.1x09.Throwaway.WS.XviDVD-TNS.avi      The.Shield.1x12.Two.Days.Of.Blood.WS.XviDVD-TNS.avi
    
    robert@rubuntu:/media/disk/woking$ find . -type f -name "*.avi" -o -name "*.mkv" -exec mencoder "{}" -oac lavc -ovc lavc -of lavf -lavcopts aglobal=1:vglobal=1:vcodec=mpeg4:vbitrate=2500:acodec=libfaac -af lavcresample=48000 -vf scale=320:240,harddup -lavfopts format=psp -ofps 30000/1001 -o "{}.mp4" \;
    robert@rubuntu:/media/disk/woking$

  6. #19

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,866
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    Drop the -exec part, do you get the right list of files?

  7. #20

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,531
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    yep sorry i almost added that this morn. i tried to break it down into segments but couldnt figure it out .

  8. #21

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,866
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    Basically anything after the -exec gets executed literally, up to the '\;' and with '{}' substituted with the filename. Does mencode have a verbose option?

  9. #22

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Quote Originally Posted by powdarrmonkey View Post
    No need to fork anything:

    Code:
    find . -type f -name "ntuser.dat" -mtime +90
    Thanks for that; it helps (need to replace the "." with $folder inside the loop so it starts at the right location and I've added -maxdepth 1 because the only ntuser.dat is going to be at the top level of the profile) but what I think I want (and it's a bit vague because this is a very messy project!) is to get a report of everything and then extract the old ones so they can be deleted/archived/whatever.

    As it stands, this will give me a list that shows old ntuser.dat files and then no details when the file is newish and that will probably do.

    I think the awk method is probably the right way to go to clean up the output - I'll keep playing :-)

  10. #23

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Thanks - I've got almost what I wanted now by just bashing my head against the wall a few times :-)

    Code:
    for folder in `find . -type d -iname '*.pds' -maxdepth 1`
    do
      find $folder -iname ntuser.dat -printf "%h %TY-%Tm-%Td\n"
      du $folder -hc | grep total | awk '{printf $1 "\n"}'
    done
    Just some notes for me to find later ...

    first line finds all the directories matching "*.pds", only going down 1 level and sets up a loop to process them

    next find statement searches from that folder using a case insensitive search for files called ntuser.dat When it finds them, it prints the name of the parent directory then the year, month and day on which the file was last modified
    du shows the folder size(s) from $folder down; the grep command just finds the one which says "total" and the awk statement returns field 1 only (just loses the word "total" to make it a bit tidier)

    I end up with output looking like this:

    ./spmoon.pds 2008-10-24
    2.0M
    ./jstoppa.pds 2008-08-19
    3.4M

    which is probably good enough for now.

  11. #24

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,531
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    not sure about a verbose mode. will have a play when i can get to a pc

  12. #25

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,531
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    mencoder -v doesnt seem to do anything... but the program is very vocal with displaying whats going on when it is working...

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. bash to GUI
    By RabbieBurns in forum *nix
    Replies: 17
    Last Post: 27th May 2010, 10:32 AM
  2. Replies: 4
    Last Post: 19th March 2009, 02:35 PM
  3. bash script doesnt like folders with spaces
    By RabbieBurns in forum Scripts
    Replies: 20
    Last Post: 12th February 2009, 12:28 PM
  4. Simple PHP script for notes about students?
    By ChrisS in forum Scripts
    Replies: 1
    Last Post: 29th November 2007, 10:25 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •