Sponsored Content
Top Forums Shell Programming and Scripting Rename files to match file list pattern Post 302975127 by lxdorney on Wednesday 8th of June 2016 12:21:38 PM
Old 06-08-2016
Rename files to match file list pattern

Hi All,

I have 100 folders with the first delimiter has a unique name i.e (123_hello and 575_hello) and each folder have atlist 1000 plus files with naming convention i.e (575_hello_1.iso ... 575_hello_1000.iso).

Code:
575_hello/575_hello_1.iso
575_hello/575_hello_2.iso
575_hello/575_hello_3.iso
...
575_hello/575_hello_1000.iso

and

Code:
123_hello/123_hello_1.iso
123_hello/123_hello_2.iso
123_hello/123_hello_3.iso
...
123_hello/123_hello_1000.iso

What I want to do is rename all the iso files in the folders to match the pattern in my file list. like

Code:
575_hello/8888_hello_1.iso
575_hello/8888_hello_2.iso
575_hello/8888_hello_3.iso
...
575_hello/8888_hello_1000.iso

and

Code:
123_hello/9999_hello_1.iso
123_hello/9999_hello_2.iso
123_hello/9999_hello_3.iso
...
123_hello/9999_hello_1000.iso

Here is my pattern list

Code:
#cat pattern.txt
575 8888
123 9999

Thanks



Moderator's Comments:
Mod Comment Please use code tags as required by forum rules!

Last edited by RudiC; 06-08-2016 at 02:03 PM.. Reason: Added code tags.
 

10 More Discussions You Might Find Interesting

1. IP Networking

List files that do not match the search pattern

I need to list the files that do not match the search pattern: Example: cat file1 This is how it should work cat file2 This is why I like Unix grep -option? Unix * (or some other command) returns file1 (1 Reply)
Discussion started by: olapxpert
1 Replies

2. UNIX for Dummies Questions & Answers

List files that do not match the search pattern

I need to list the files that do not match the search pattern: Example: cat file1 This is how it should work cat file2 This is why I like Unix grep -option? Unix * (or some other command) returns file1 (7 Replies)
Discussion started by: olapxpert
7 Replies

3. Shell Programming and Scripting

Batch rename files after internal search pattern

Hello all I am trying to do a script that would allow me to mass rename files after a grep search within them. They are XML files and the pattern I would like to append to the file name is easy to find (e.g. <filename>foo</filename>), but I can't for the life of me find out how to do it and... (2 Replies)
Discussion started by: aavv
2 Replies

4. Shell Programming and Scripting

AWK match $1 $2 pattern in file 1 to $1 $2 pattern in file2

Hi, I have 2 files that I have modified to basically match each other, however I want to determine what (if any) line in file 1 does not exist in file 2. I need to match column $1 and $2 as a single string in file1 to $1 and $2 in file2 as these two columns create a match. I'm stuck in an AWK... (9 Replies)
Discussion started by: right_coaster
9 Replies

5. Shell Programming and Scripting

Batch rename files that do not match pattern

Hi all, I do not have programming experience and mostly use one-liner or sometimes more to get the job done. I am having problem to batch rename the files that do not match a particular pattern. Sample file-names from directory: Meeting_Packages.pdf 13_textfile0 19_textfile0 ... (3 Replies)
Discussion started by: atulkakrana
3 Replies

6. Shell Programming and Scripting

Help needed - Split large file into smaller files based on pattern match

Help needed urgently please. I have a large file - a few hundred thousand lines. Sample CP START ACCOUNT 1234556 name 1 CP END ACCOUNT CP START ACCOUNT 2224444 name 1 CP END ACCOUNT CP START ACCOUNT 333344444 name 1 CP END ACCOUNT I need to split this file each time "CP START... (7 Replies)
Discussion started by: frustrated1
7 Replies

7. Shell Programming and Scripting

Rearrange or replace only the second line after pattern match or pattern match

Im using the command below , but thats not the output that i want. it only prints the odd and even numbers. awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}' Im hoping for something like this file1: Text hi this is just a test text1 text2 text3 text4 text5 text6 Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies

8. Shell Programming and Scripting

Rename specific file extension in directory with match to another file in bash

I have a specific set (all ending with .bam) of downloaded files in a directory /home/cmccabe/Desktop/NGS/API/2-15-2016. What I am trying to do is use a match to $2 in name to rename the downloaded files. To make things a more involved the date of the folder is unique and in the header of name... (1 Reply)
Discussion started by: cmccabe
1 Replies

9. Shell Programming and Scripting

Bash to rename portion of file using match to another

In the portion of bash below I am using rename to match the $id variable to $file and when a match (there will alwsys be one) is found then the $id is removed from each bam and bam.bai in $file and _test is added to thee file name before the extension. Each of the variables is set correctly but... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. Shell Programming and Scripting

Rename file using partial match to another

In the below I am trying to rename the contents within each data subfolder in a specific run, based on a partial match of the IonCode_0000_ in each file in the data subdirectory to $1 in f1. There will be multiple runs in f1 but each run in $uniq is unique and will be found in f1 and the rename... (27 Replies)
Discussion started by: cmccabe
27 Replies
ISO-READ(1)							   User Commands						       ISO-READ(1)

NAME
iso-read - manual page for iso-read version 0.83 i686-pc-linux-gnu SYNOPSIS
iso-read OPTION... Reads portions of an ISO 9660 image. DESCRIPTION
-d, --debug=INT Set debugging to LEVEL. -i, --image=FILE Read from ISO-9660 image. This option is mandatory -e, --extract=FILE Extract FILE from ISO-9660 image. This option is mandatory. -k, --ignore Ignore read error(s), i.e. keep going --no-header Don't display header and copyright (for regression testing) -o, --output-file=FILE Output file. This option is mandatory. -V, --version display version and copyright information and exit Help options: -?, --help Show this help message --usage Display brief usage message AUTHOR
Rocky Bernstein <rocky@gnu.org> COPYRIGHT
Copyright (C) 2003, 2004, 2005, 2007, 2008, 2011 R. Bernstein This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. Have driver: GNU/Linux ioctl and MMC driver Have driver: cdrdao (TOC) disk image driver Have driver: bin/cuesheet disk image driver Have driver: Nero NRG disk image driver Default CD-ROM device: /dev/scd0 SEE ALSO
iso-info(1) for information about an ISO-9660 image. cd-read(1) to read portions of an ISO 9660 image. iso-read version 0.83 i686-pc-linux-gnu October 2011 ISO-READ(1)
All times are GMT -4. The time now is 10:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy