Sponsored Content
Top Forums Shell Programming and Scripting Bash to add unique prefix to extracted zip folder Post 303032723 by cmccabe on Friday 22nd of March 2019 01:39:37 PM
Old 03-22-2019
Bash to add unique prefix to extracted zip folder

In the bash below in each .zip there is a folder to be extracted Variants that I am trying to make unique by adding the prefix, before the _ from the .zip. The script does execute, but the prefix is not added to the extracted folder. Rather the Variants folder is added to each file within it. Thank you Smilie.

bash
Code:
for z in /home/cmccabe/tmp/*.zip; do ## start loop
    unzip "$z";  ## unzip all .zip files
    mv "$(unzip -Z1 $z)" "${z%%_*}";  ## grab prefix before _ and add to the extraced .zip
rm "$z"  ## remove original .zip
done  ## end processing


/home/cmccabe/tmp
Code:
19-0000-LastName-FirstName_v1_c91a684a-0a9c-4632-9b60-91f0d337f51d.zip --- top level ---
     Variants   --- folder to be extracted ---
19-0002-L-F_v1_d870b844-b72e-49c4-89c4-471f90dd8724.zip   --- top level --
     Variants   --- folder to be extracted ---

desired output --- zip extracted ---
Code:
     19-0000-LastName-FirstName-Variants   --- extracted folder w/ prefix ---
     19-0002-L-F-Variants   --- extracted folder w/ prefix ---

example after executing currently --- one of 5 files, all extated in the same way ---
Code:
 inflating: Variants/19-0000-LastName-FirstName_v1/19-0000-LastName-FirstName_v1_Non-Filtered_2019-03-21_08:12:52-xxxx.tsv


Last edited by cmccabe; 03-23-2019 at 11:40 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

zip a folder

is it possible to zip a whole folder instead of each file individually? (3 Replies)
Discussion started by: rprules
3 Replies

2. UNIX for Dummies Questions & Answers

Zip a folder including its sub-folders.

Hi, I have a folder that contains a few sub-folders. I would like to zip that folder and KEEP the subfolders. What it does at the moment is taking all the files within the subfolders and zipping them into one big file (zip -r ...). Does anyone know the UNIX command to keep the subfolders in the... (3 Replies)
Discussion started by: gdog
3 Replies

3. Shell Programming and Scripting

Zip the folder

i want the scripts or unix command to zip the folder. (3 Replies)
Discussion started by: kingganesh04
3 Replies

4. Windows & DOS: Issues & Discussions

How can I upload a zip folder on a unix path from my windows folder?

Hello, I am an amature at UNIX commands and functionality. Please could you all assist me by replying to my below mentioned querry : How can I upload a zip folder on a unix path from my windows folder? Thanks guys Cheers (2 Replies)
Discussion started by: ajit.yadav83
2 Replies

5. UNIX for Dummies Questions & Answers

Zip command (zip folder doesn't include a folder of the same name)

Hi guys, I have a question about the zip command. Right now I have a directory with some files and folders on it that I want to compress. When I run the zip command: zip foo -r I am getting a foo.zip file that once I unzip it contains a foo folder. I want to create the foo.zip, but that... (1 Reply)
Discussion started by: elioncho
1 Replies

6. UNIX for Dummies Questions & Answers

isolate unique files in a folder

Hello, I have two folders. One has 1183 text files (folder A). The other (folder B) has 1160 of those 1183 files (the contents in these 1160 files are identical to the contents in the corresponding files in the other folder, but the names of the files in this folder are completely different... (2 Replies)
Discussion started by: juliette salexa
2 Replies

7. UNIX and Linux Applications

Zip command for large folder

I am trying to zip a folder, its size is more than 3 GB. I used below command zip -r foo middleware -x "*path*" This command fails every time with message "Filesize exceeded limit" Can some one help me how to over come this problem and zip the entire folder without splitting it. ... (2 Replies)
Discussion started by: ariram
2 Replies

8. Shell Programming and Scripting

Find all images, append unique prefix to name and move to different directory

Hi, I have a directory with Multiple subdirectories and 1000s of pictures (jpg) in each directory. The problem is that each directory has a 001.jpg in them. I want to append a unique name (the directory_name)would be fine. and then move them to one main backup directory once they have been... (1 Reply)
Discussion started by: kmaq7621
1 Replies

9. Shell Programming and Scripting

Bash to add folder to exsisting folders in directory

I am trying to create subdirectories in each folder in /home/cmccabe/Desktop/NGS/test/*. When I use echo I can see each folder in the directory, but I can not seem to add the commented out portion in bold. These are the sub-directories and sub-folders I am trying to add to each folder in... (1 Reply)
Discussion started by: cmccabe
1 Replies

10. Shell Programming and Scripting

Add coordinates to line of output extracted from input file

I am trying to compare/confirm the output of an script using the perl below, which does execute. However I can not seem to print $1 and $2 in each line of the input separated by a tab in each line of the output. The input file is quite large so I have only included a portion, but the format is the... (0 Replies)
Discussion started by: cmccabe
0 Replies
RMF(1)                                                               [nmh-1.5]                                                              RMF(1)

NAME
rmf - remove an nmh folder SYNOPSIS
rmf [+folder] [-interactive | -nointeractive] [-version] [-help] DESCRIPTION
Rmf removes all of the messages (files) within the specified (or default) folder, and then removes the folder (directory) itself. If there are any files within the folder which are not a part of nmh, they will not be removed, and an error will be produced. If the folder is given explicitly or the -nointeractive option is given, then the folder will be removed without confirmation. Otherwise, the user will be asked for confirmation. If rmf can't find the current folder, for some reason, the folder to be removed defaults to `+inbox' (unless overridden by user's profile entry "Inbox") with confirmation. If the folder being removed is a subfolder, the parent folder will become the new current folder, and rmf will produce a message telling the user this has happened. This provides an easy mechanism for selecting a set of messages, operating on the list, then removing the list and returning to the current folder from which the list was extracted. If rmf s used on a read-only folder, it will delete all the (private) sequences (i.e., "atr-seq-folder" entries) for this folder from your context without affecting the folder itself. Rmf irreversibly deletes messages that don't have other links, so use it with caution. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder Inbox: To find the default inbox SEE ALSO
rmm(1) DEFAULTS
`+folder' defaults to the current folder, usually with confirmation `-interactive' if +folder' not given, `-nointeractive' otherwise CONTEXT
Rmf will set the current folder to the parent folder if a subfolder is removed; or if the current folder is removed, it will make "inbox" current. Otherwise, it doesn't change the current folder or message. BUGS
Although intuitively one would suspect that rmf works recursively, it does not. Hence if you have a sub-folder within a folder, in order to rmf the parent, you must first rmf each of the children. MH.6.8 11 June 2012 RMF(1)
All times are GMT -4. The time now is 06:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy