Rename files that are inside zip file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Rename files that are inside zip file
# 1  
Old 02-06-2012
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
# 2  
Old 02-07-2012
Code:
while read file
do
 echo mv $file ${file#*_}
done < file_contains_list_of_filename


Test, verify and then remove the "echo".
# 3  
Old 02-07-2012
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

2. Shell Programming and Scripting

Work with file inside zip

Hi all, I`m trying to find 3 files from all zip files in a directory (and its all its subdirectories) recursively, and concatenate them correspondingly along with the filename (possibly path of that file from current directory). Suppose I have 3 zips a123.zip a234.zip a456.zip ... (2 Replies)
Discussion started by: senhia83
2 Replies

3. Shell Programming and Scripting

Loop through the dir and Rename zip files and their underlying text file.

I have files in the ABC_YYYYMMDD.zip format under a directory. Each zip file contains A text file in the ABC_YYYYMMDD.txt format. I am trying to create a script that will Rename the zip files and their underlying text file replacing the datepart in them with . For eg: in the case of... (1 Reply)
Discussion started by: bash987
1 Replies

4. Shell Programming and Scripting

Rename files in ZIP file

Hi guys, I want to change the name of zip file and the files in zip. eg. there are two zip files 100_ABC_20101020.zip 101_ABC_20101020.zip 100_ABC_20101020.zip | --100_A_20101020.txt --100_B_20101020.txt --100_C_20101020.txt 101_ABC_20101021.zip | ... (0 Replies)
Discussion started by: ambious
0 Replies

5. Shell Programming and Scripting

Searching for a string in .PDF files inside .RAR & .ZIP archives.

Hi, I have got a large number of .PDF files that are archived in .RAR & ZIP files in various directories and I would like to search for strings inside the PDF files. I would think you would need something that can recursively read directories, extract the .RAR/.ZIP file in memory, read the... (3 Replies)
Discussion started by: lewk
3 Replies

6. Shell Programming and Scripting

Script to rename zip-files with name of file

Hi, I'm desperately in search for a solution of the following problem: I have a directory full of zip-files. All these zip-files contain a single file with a name that should be used for the name of the zip-container. Anybody a good idea. I'm an absolute beginner in shell scripting - so please... (7 Replies)
Discussion started by: mark_a17
7 Replies

7. Shell Programming and Scripting

Rename contents inside multiple files

Hi, I have 100 files in a directory. Each file have the following format >CtbRe01234 fdfjdhfkdfkd >CtL2B0456 gjfgfkgjfkgjfk >CmdrE05768 fghdjskksllfkLike this I have many files in the directory. What I want is; rename the header content in each file such that the above file... (6 Replies)
Discussion started by: Lucky Ali
6 Replies

8. Shell Programming and Scripting

grep inside the zip file

i have to grep a particular pattern say "meter number" in 100s of zip files file1.zip : : : : file100.zip how to achive this? cat *.zip | grep "meter number" also i dnt want to unzip and then grep it...... hope i made myself clear. thanks in advance (5 Replies)
Discussion started by: ali560045
5 Replies

9. Shell Programming and Scripting

Hello - new here - bash script - need to rename and zip files.

I'm working on a project that basically unzips three zip files. When these unzip they create about 70+ directories with subdirectories of year/month with about 3 to 9 pdf files in each directory. Basically, I'm needing to figure out a way to zip these pdf files up. for instance the script... (1 Reply)
Discussion started by: Aixia
1 Replies

10. UNIX for Dummies Questions & Answers

unzip .zip file and list the files included in the .zip archive

Hello, I am trying to return the name of the resulting file from a .zip archive file using unix unzip command. unzip c07212007.cef7081.zip Archive: c07212007.cef7081.zip SecureZIP for z/OS by PKWARE inflating: CEP/CEM7080/PPVBILL/PASS/G0063V00 I used the following command to unzip in... (5 Replies)
Discussion started by: oracledev
5 Replies
Login or Register to Ask a Question