|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Rename files that are inside zip file
Hello to all, I have a zip file with any name like FileName.zip, within the zip file there are more than 30 files with different extensions in the following format. Code:
FileName_BMN_ROSJ.txt FileName_THEUS.jpg . . . FileName_KWPWP.shx I would like to unzip the file and rename each file inside removing the first part "FileName_" thinking that "FileName" could have spaces. The unzipped files must be named as below: Code:
BMN_ROSJ.txt THEUS.jpj . . . KWPWP.shx May somebody help with this. Any help will be appreciated. Greetings |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
Code:
while read file
do
echo mv $file ${file#*_}
done < file_contains_list_of_filenameTest, verify and then remove the "echo". |
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
Hi anchal_kare,
Thank for your reply. I wasn't able to get the correct regex to use within sed to rename the files, but using that bash option "${fname#*_}" was the way I could do it unzipping first the file and then renaming each file inside the zip. Thanks again. Greetings |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Rename files with tag in a .xml file | crusty | Shell Programming and Scripting | 4 | 01-25-2012 06:55 AM |
| Rename the files with .xls file | murari83.ds | Shell Programming and Scripting | 6 | 07-20-2011 02:00 PM |
| Script to rename zip-files with name of file | mark_a17 | Shell Programming and Scripting | 7 | 05-11-2010 05:09 AM |
| awk a text file, use loop to copy files, rename file | manouche | Shell Programming and Scripting | 3 | 04-12-2010 02:05 PM |
| Rename contents inside multiple files | Lucky Ali | Shell Programming and Scripting | 6 | 02-16-2010 12:12 PM |
|
|