• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AS or Unix tools for turning find result into a nice consistent tab separated text file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AS or Unix tools for turning find result into a nice consistent tab separated text file?


  • Subject: AS or Unix tools for turning find result into a nice consistent tab separated text file?
  • From: Richard Rönnbäck <email@hidden>
  • Date: Sat, 10 Jun 2006 11:53:26 +0200
  • Thread-topic: AS or Unix tools for turning find result into a nice consistent tab separated text file?

Title: AS or Unix tools for turning find result into a nice consistent tab separated text file?
I am trying to find the fastest possible way of getting information for specific file types and turn it into a tab separated text file for import to a database. After spending tens of hours or so banging my head against regular _expression_ etc. I am only a little bit closer and nowhere near a full solution.  Before I jump into looping and treating each line with AppleScript (the find result may be up to 100 000 lines long ) I would greatly appreciate some input and good advice.

The text file I need must contain:

* file path
* Year of modification date as YYYY
* Month of modification date as  MM (numbers)
* Day of modification date as  DD (numbers)
* Time of modification date as  HH:HH (24 hour format)
* File size in bytes
* File inode number

In other word the result file should look something like this

    /Images/somefile.jpg    2005    06  02  14:42   45678   1123456



What I have so far is the shell find part, which looks like this:

    find ~/Desktop -iname *.jpg -o -iname *.tif -o -iname *.eps  -o -iname *.psd  -a  ! -name '.*' -type f -ls >~/Desktop/allfiles.txt


The resulting files may then look like this:

    4136284 1120 -rw-r--r--    1 richardr wheel      527927 May  1 17:53 /Users/richardr/Desktop/LOGOTYPE/rr_logo_100x100 endast symbol.psd
    1746034 1160 -rwx------    1 richardr richardr   593360 Mar 26  2001 /Users/richardr/Desktop/Städa/Indesign/Bakgrunder/åker.psd


Even though this is a good start, some of my remaining problems are:
1) Removing unwanted parts
2) Turning spaces into tabs (without ruining file paths containing spaces)
3) Adding actual year to files more recent than six months, and a mock-up time "00:00" to files older than six months
4) Changing the column order to match my requirements


Something that complicates matters (i guess) are that file paths will contain spaces and/or Unicode characters.

I have been trying  this

    grep '^[0123456789]\+' -o ~/Desktop/allfiles.txt

which finds all inode numbers

and this

    grep ' [0123456789]\+ [A-Z][:lower:].\+' -o ~/Desktop/allfiles.txt

which finds all file sizes and the rest of the information.

But how do I combine the two??? (or rather exlude tha parts I dont wan't)


Can I at all achieve what I want with "simple" shell tools, or must this be a Perl or Python script or something like that, or am I just best of looping each line with AppleScript ??


Any help is much appreciated




// Richard
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: AS or Unix tools for turning find result into a nice consistent tab separated text file?
      • From: Christopher Nebel <email@hidden>
    • Re: AS or Unix tools for turning find result into a nice consistent tab separated text file?
      • From: Gnarlodious <email@hidden>
    • Re: AS or Unix tools for turning find result into a nice consistent tab separated text file?
      • From: Emmanuel <email@hidden>
    • Re: AS or Unix tools for turning find result into a nice consistent tab separated text file?
      • From: Björn Lundin <email@hidden>
References: 
 >Re: Problem with Reply, Forward and Outgoing Messages in Application "Mail" (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: Problem with Reply, Forward and Outgoing Messages in Application "Mail"
  • Next by Date: Re: AS or Unix tools for turning find result into a nice consistent tab separated text file?
  • Previous by thread: Re: Problem with Reply, Forward and Outgoing Messages in Application "Mail"
  • Next by thread: Re: AS or Unix tools for turning find result into a nice consistent tab separated text file?
  • Index(es):
    • Date
    • Thread