image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old March 3rd, 2006, 01:50 PM
AI
 
Join Date: Sep 2002
Location: Boston, MA
Posts: 118
Thanks: 0
Thanked 0 Times in 0 Posts
jackdahi is on a distinguished road
Question Help renaming a directory!

Ok so renaming a directory is easy in unix. But here is the difficult task:

Im using the tcsh shell to write a basic script that moves certain logs to a folder at a certain time. This folder's name needs to be the current date. Moving the files is simple, but automatically generating a directory with the current date has proven difficult.

Can anyone help me?
Reply With Quote
  #2  
Old March 3rd, 2006, 03:37 PM
tomdkat's Avatar
Registered User
 
Join Date: Aug 2005
Posts: 197
Thanks: 6
Thanked 0 Times in 0 Posts
tomdkat is on a distinguished road
Try using the date command, like this:

$ mkdir test-`date +%F`-dir
$ dir -ld test*
drwxrwxr-x 2 tom tom 4096 Mar 3 14:26 test-2006-03-03-dir
$

Read the man page on the various formatting options and specify them after the "+" sign as appropriate. Be sure to keep the single quote marks (`), as I have in my example above, as they instruct the shell to run the command enclosed in them and substitute the output in place where the command appears.

Good luck!

Peace...
Reply With Quote
  #3  
Old March 3rd, 2006, 05:36 PM
AI
 
Join Date: Sep 2002
Location: Boston, MA
Posts: 118
Thanks: 0
Thanked 0 Times in 0 Posts
jackdahi is on a distinguished road
tomdkat you are the man...lol

Thanks for taking the time to help me with this. I will format it to my needs but I got the just of it. I'm glad to see that i can count on this forum and its members.

Thanks again!
Reply With Quote
  #4  
Old March 3rd, 2006, 05:38 PM
tomdkat's Avatar
Registered User
 
Join Date: Aug 2005
Posts: 197
Thanks: 6
Thanked 0 Times in 0 Posts
tomdkat is on a distinguished road
Naw, I'm not "the man"... just trying to help out.

I've used the date command to do things like naming files based on a date/time stamp and it can work out very well when used right.

Good luck and let us know how it works out for you.

Peace...
Reply With Quote
  #5  
Old March 4th, 2006, 10:37 AM
Registered User
 
Join Date: Mar 2005
Posts: 197
Thanks: 0
Thanked 1 Time in 1 Post
artov is on a distinguished road
Quote:
Originally Posted by jackdahi
Im using the tcsh shell to write a basic script that moves certain logs to a folder at a certain time.
On the tcsh shell: check http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Ok, it is about csh, but to my knowledge tcsh is mainly enhanced commandline
stuff (edition etc.). So: use bash or sh instead.
Reply With Quote
  #6  
Old March 4th, 2006, 10:50 AM
tomdkat's Avatar
Registered User
 
Join Date: Aug 2005
Posts: 197
Thanks: 6
Thanked 0 Times in 0 Posts
tomdkat is on a distinguished road
Quote:
Originally Posted by artov
On the tcsh shell: check http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Ok, it is about csh, but to my knowledge tcsh is mainly enhanced commandline
stuff (edition etc.). So: use bash or sh instead.
I dunno, I've used csh, tcsh, bash, sh, and ksh and I don't see any problem with using csh. I do agree that one should also be proficient in sh (even more so than ksh or bash) in the interest of being functional across a broader spectrum of *nix systems.

In this case and for what he's wanting to do, (t)csh will work just fine.

Peace...
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
files renaming insomnia Mac OS X System & Mac Software 2 February 27th, 2006 03:49 PM
batch renaming files 27 houdini's Mac OS X System & Mac Software 4 September 20th, 2004 03:24 AM
Renaming hd Borrmaskin Mac OS X System & Mac Software 1 January 13th, 2003 06:28 AM
Annyoing renaming, also in Jaguar? Kris Mac OS X System & Mac Software 6 June 2nd, 2002 06:05 PM


All times are GMT -5. The time now is 01:22 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.