Results 1 to 4 of 4
I am using the following script to rename all file in a directory.
for i in *;
do mv "$i" "$(date +%Y_%m_$(echo $i |sed s/file// |sed s/.jpg//))".jpg;
done
I just ...
- 02-13-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 4
rename files I am stuck
I am using the following script to rename all file in a directory.
for i in *;
do mv "$i" "$(date +%Y_%m_$(echo $i |sed s/file// |sed s/.jpg//))".jpg;
done
I just want the Date/Time stamp in the filename, not Date/Time/originalfilename.
I want to drop the original filename when the files are renamed.
Please Help I am stuck.
- 02-14-2009 #2
This will work and help you avoid collisions in filenames:
I coudnt definitively tell, but were you trying to keep the file extension?Code:for i in *; do echo mv "$i" "$(date +%Y_%m_)$RANDOM"; done
Are they always going to be jpg files, or could it be any file type?
- 02-14-2009 #3Just Joined!
- Join Date
- Feb 2009
- Posts
- 4
Yes they are always JPG's thanks your code works great.
- 02-14-2009 #4Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
Hi jimaki141, I didn't spot your post in the other thread. Did you get the space handling sorted out or was that still causing problems?


Reply With Quote