newbie -- please help: sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting newbie -- please help: sed
# 1  
Old 08-15-2011
Power newbie -- please help: sed

Hi

I am trying to setup a sed script that will rename all files in a folder to their date and time stamp.

eg:

Code:
 
xxxxx.jpg
xxxxx12.jpg
xxxxx14.jpg

they need to be renamed to
upstairs `date +%Y%m%d`.jpg
They have no metadata, so cannot use exif, will need to use sed.

Thanks in advanceSmilie

Last edited by radoulov; 08-15-2011 at 03:46 AM.. Reason: Code tags.
# 2  
Old 08-15-2011
Code:
 
d=`date +%Y%m%d`; for i in *.jpg; do newName=`basename $i .jpg`; echo "mv $i $i$d.jpg"; done

test the above and check the echo output. If everything is ok, then remove the echo part and execute it
# 3  
Old 08-15-2011
HI,
Thanks for getting back so quickly -- was at work -- so tried it just now.

I am getting the following error:
Code:
mv 00606E931288(Indoor UP)_1_20110815190759_625.jpg 00606E931288(Indoor UP)_1_20110815190759_625.jpg20110815.jpg
basename: extra operand `.jpg'
Try `basename --help' for more information.
mv 00606E931288(Indoor UP)_1_20110815190828_625.jpg 00606E931288(Indoor UP)_1_20110815190828_625.jpg20110815.jpg
mv new.jpg new.jpg20110815.jpg

I want the time to be the time that the file was created -- I guess this will show the time of executing the script -- am I correct -- if so -- how do we do that?

Thanks

Last edited by Scott; 08-15-2011 at 03:55 PM.. Reason: Code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed newbie question

hi all: i am trying to use sed to separate hex bytes "363834574e292c20" to "36 38 34 57 4e 29 2c 20". i used the following script (googled) and i got "3 63 83 45 74 e2 92 c2 0". how could i modify the script to meet my needs? thanks (8 Replies)
Discussion started by: ipfreak
8 Replies

2. Shell Programming and Scripting

sed newbie scripting assistance

Howdy folks, I'm trying to craft a log file summarisation tool for an application that creates a lot of duplicate entries with only a different suffix to indicate point of execution. I thought I'd gotten close but I'm clearly missing something. Here's a genericized version: A text_file... (3 Replies)
Discussion started by: mthespian
3 Replies

3. UNIX for Dummies Questions & Answers

Sed Newbie Question

Hello everyone I could really need some help. I want to rename : with dot. But the problem is that i don't want to touch the hours like 12:00 but i want to change AD:FG with AD.FG. I'm thinking something like : to . I don't know if i explain it corrrectly but i could use some help Thanks... (20 Replies)
Discussion started by: zoe
20 Replies

4. Shell Programming and Scripting

perl newbie . &&..programming newbie

Hi, I am new to programming and also to perl..But i know 'perl' can come to my rescue, But I am stuck at many places and need help..any small help is much appreciated... below is the description of what i intend to acheive with my script. I have a files named in this format... (13 Replies)
Discussion started by: xytiz
13 Replies

5. Shell Programming and Scripting

perl newbie . &&..programming newbie (question 2)

Hello everyone, I am having to do a lot of perl scripting these days and I am learning a lot. I have this problem I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files.. there is folder1\folder2\*.gz and there are about 50 folders... (1 Reply)
Discussion started by: xytiz
1 Replies

6. UNIX for Dummies Questions & Answers

UNIX newbie NEWBIE question!

Hello everyone, Just started UNIX today! In our school we use solaris. I just want to know how do I setup Solaris 10 not the GUI one, the one where you have to type the commands like ECHO, ls, pwd, etc... I have windows xp and I also have vmware. I hope I am not missing anything! :p (4 Replies)
Discussion started by: Hanamachi
4 Replies

7. Shell Programming and Scripting

SED question: newbie here.

Hello... I wanted to figure out how to remove the 1st instance of a comma from a file.. 100+ line file ------------- 'test1' ,'dudes are cool' <-- remove comma from first instance of comma in file ,'cool dude' ,'bbbbbb' I tried everything from cat jigar|tr , >1.txt to cat jigar|sed... (2 Replies)
Discussion started by: jigarlakhani
2 Replies

8. Shell Programming and Scripting

Need Help with AWK or SED (Newbie)

Hello, I have a text file in below format, how do I put a header and assign field names to the file with either AWK or SED STRT~ VA ~23606 ~TM14~8506~1485 (page 1) STRT~ VA ~23662 ~TM17~8362~1783 (page 2) STRT~ VA ~23662 ~TM17~8362~1783 STRT~ VA ~23662 ~TM17~8362~1783 STRT~ VA ~23662... (1 Reply)
Discussion started by: udaybo
1 Replies

9. Shell Programming and Scripting

SED Newbie

I'm trying to figure out how to basically replace a line in a text file using Sed. Here's what I need sed to do: I have a file with passwords that are in use. Each month the passwords need to be swapped out with passwords stored in another file. I want to use Sed (or Awk ... or possibly both)... (3 Replies)
Discussion started by: cpslo09
3 Replies

10. Shell Programming and Scripting

Newbie using sed in a shell script

I'm sure this is an easy one but I can't seem to get it working. Given the following: for oldName in `ls *.JPG` ;do newName=<confusion here. how to make sed perform 's/.JPG/_thumb.JPG/g' operation on $oldName> done Could someone show me what I'm doing wrong? Thanks Ken (1 Reply)
Discussion started by: ktoz
1 Replies
Login or Register to Ask a Question