X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <47F1954D.8000204@gmail.com> Date: Mon, 31 Mar 2008 19:52:13 -0600 From: Morgan gangwere <0 DOT fractalus AT gmail DOT com> User-Agent: Thunderbird 2.0.0.12 (X11/20080227) MIME-Version: 1.0 To: the somewhat professional and usually very helpful cygwing mailing list Subject: Re: Cygwin is saving my ass References: <029401c88e79$31038380$2708a8c0 AT CAM DOT ARTIMI DOT COM> <47ED2527 DOT 40100 AT gmail DOT com> <31b7d2790803292207v234a7478q9b45ed9c1af9e52f AT mail DOT gmail DOT com> In-Reply-To: <31b7d2790803292207v234a7478q9b45ed9c1af9e52f@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com DePriest, Jason R. wrote: > On Fri, Mar 28, 2008 at 12:04 PM, Morgan gangwere <> wrote: >> Without cygwin, i wouldnt have my directory sorting algorithm running on >> windows. DOS has no way of (easily) sorting files into >> c:\{YEAR}\{MONTH}\{MIMETYPE}\ >> (where Year Month and Mimetype are the year month and mimetype of the >> file in a list of oh say 30000 files.) >> >> i _could_ impliment this in vb, but bash is faster. >> -- >> Morgan Gangwere >> >> Unknown Software >> > > Any chance you could share your bash script? I have some perl scripts > that are similar, but a pure bash script would be even better. > > -Jason > Its somwhere in my log... the basic idea is you have 2 shell scripts, one that does the move, another one that handles the list. dotree.sh looks something like --- start --- # Get all files in cmd line: for $f in $* echo "copy $f" fcopy $f >> stdout rof --- end -- and fcopy looks like --- start --- $fname = $1 #we can assume the file exists, as a glob was proabably used # get the modify date and mimetype $finfo={date =r=$fname +%Y_%j_%R} $mime = {file -i $finfo} $outname={basename $fname} # now we copy the file $TARGET = "\cygdrive\m\backups\$DATE" echo "Copying $fname to $TARGET\$finfo\$mime\$outname" >> stdout cp $fname "$TARGET\$finfo\$mime\$outname" --- end --- This will send the file "foo.txt" modified 3/14/15 at 06:06:06 to \cygdrive\m\backups\(todays date)\15_(day number for march 14)_06:06:06\text/plain; charset=us-ascii\foo.txt" Note that this can be a VERY useful system if you have a bunch of files and you can easily pick "foo.txt modified on blah", as this script will do it, and thats how my backup works. this MAY fail if you have multiple "foo.txt"s modified on the same day note that is will fail as you cant cp files like that. but it is possible to use this as a base -- i am recalling this from memory. -- Morgan Gangwere Unknown Software -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/