![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| script for Finding files in a folder and copying to another folder | satish2712 | Shell Programming and Scripting | 5 | 09-11-2008 04:07 PM |
| Auto copy for files from folder to folder upon instant writing | Bashar | UNIX for Advanced & Expert Users | 2 | 08-21-2008 02:44 PM |
| Moving Files from one folder to another folder | farooqpervaiz | Shell Programming and Scripting | 10 | 08-07-2008 02:20 AM |
| rename files help | piltrafa | UNIX for Dummies Questions & Answers | 2 | 10-04-2007 09:47 AM |
| How to rename files? | CompuTelSystem | UNIX for Dummies Questions & Answers | 9 | 05-14-2002 03:28 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
rename files in a folder
i have a folder that contains 100's of files: abc, bca, def, ghi....
i want to rename abc with 1, bca with 2, def with 3, ghi with 4 and so on. my way, i create a file.txt with contents: 1 2 3 4 i use while loop to rename my files. without using file.txt, i just want to rename abc with 1, and then bca with 2 by incremental. |
|
|||||
|
Code:
>ls -l | grep "^-" | cat -n | awk '{print $1","$10}'
1,afile 2,bfile etc... Then just create a loop to read through the output, renaming the second variable to the first. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|