Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Can anyone tell me if there is a method for renaming several files at once, keeping their original file name, but adding a bit of text as a prefix to the file name (such as the date or month name)?
I have a buttload of old text files and logs I'd like to archive. So assuming i have files:
alphanotes.txt
betanotes.txt
zetanotes.txt
can i use a means to rename them all at once to (for example):
I've had this problem w/ the bad interpreter and I saw nothing wrong with the script/permissions. I think it was from when I cut and paste a script from here. I fixed it by deleting it and manually typing it out. Try that and see what happens.
I tried using rename before I posted my question here. I could not figure out a way to get it to do what I needed, even after reading the man pages.
Tinkster's script works fine on my linux partition, just doesnt seem to work on the windows Fat32 partition. I just moved all the files in question to my home directory and used Tinkster's script to rename them. I'll try again another time with homey's awk and sed commands, but as i am not really familiar with either of them yet, I felt it easier to just move the files to where I knew the script would work fine.
rename_txt_files() {
for i in `ls *.txt`
do
mv "$i" "01_29_$i"
done
}
to make the function rename_txt_files, which will work like a shell script. Also, make sure the script is executable (On a FAT(32) partition, all the files have the same permissions -- make sure they include execute permission for yourself) and that the file is writeable by you (again, all the permissions are the same).
Also, you can change the line mv "$i" "01_29_$i" to mv "$i" "`date +%m_%d_`$i".
Guys, these scripts work like charm, but, how hell can I replace file names with, say, 0001.doc, 0002.doc etc... there are some hundreds files.
I need to rewrite the names which are all different, so there is no matching pattern.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.