Sponsored Content
Top Forums Shell Programming and Scripting Bash to rename portion of file using match to another Post 303039774 by cmccabe on Tuesday 15th of October 2019 06:24:55 AM
Old 10-15-2019
I do not know python well enough to write a script. php I have not used but have used bash with rename before. There probably is a better way but this was my attempt and I wanted to make a resonable attempt with what I have learned. Thank you Smilie.

Last edited by cmccabe; 10-15-2019 at 07:34 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match portion of the filename

hi, I have a script which accept filename and process them, however, one of the file needs 'special' handling so I need to identify it, say the filename contains the word "STOCK" (i.e. NEWYORKSTOCKLIST20060627.txt), I want to check if the filename contains the word "STOCK", how can I do that?... (1 Reply)
Discussion started by: mpang_
1 Replies

2. Shell Programming and Scripting

mv command to rename multiple files that retain some portion of the original file nam

Well the title is not too good, so I will explain. I need to move (rename) files using a simple AIX script. ???file1.txt ???file2.txt ???file1a.txt ???file2a.txt to be: ???renamedfile1'date'.txt ???renamedfile2'date'.txt ???renamedfile1a'date'.txt ???renamedfile2a'date'.txt ... (4 Replies)
Discussion started by: grimace15
4 Replies

3. Shell Programming and Scripting

Rename portion of file based on another file

Hello, I've been searching and reading, but I can't figure out how to solve this problem with my newbie skills. In my directory, I have a list of files (see dirlist.txt attachment) that I need to merge and rename. I have part of the code of the code figured out (see below). However, I... (3 Replies)
Discussion started by: anjulka
3 Replies

4. Shell Programming and Scripting

BASH function to rename file to last mondays date

I'm trying to create a bash function that will allow me to rename a file name emails.txt to last monday's date renem () { d=`date -d last-monday` mv ~/emails.txt ~/myemails/$d } but i en up wit this error any suggestion mv: target `2014' is not a directory (3 Replies)
Discussion started by: robshal
3 Replies

5. 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

6. Shell Programming and Scripting

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). 575_hello/575_hello_1.iso 575_hello/575_hello_2.iso 575_hello/575_hello_3.iso... (8 Replies)
Discussion started by: lxdorney
8 Replies

7. Shell Programming and Scripting

Bash to rename file after second occurence of underscore

I am trying to use bash to remove the text in all filenames after the second _ in specific files that end in .bam or .vcf. However the bash errors looking for the files in the directory. Thank you :). files in directory ... (4 Replies)
Discussion started by: cmccabe
4 Replies

8. Shell Programming and Scripting

Bash to copy file 3 times and rename based on another file

In the below bash I am trying to copy the only text file (always only one) in /home/cmccabe/Desktop/list/QC/metrics.txt and rename each of the 3 text files according to /home/cmccabe/Desktop/test/list.txt using lines 3, 4 ,5. This format (that is list.txt) is always 5 lines. Thank you :). ... (12 Replies)
Discussion started by: cmccabe
12 Replies

9. Shell Programming and Scripting

Bash to add portion of text to files in directory using numerical match

In the below bash I am trying to rename eachof the 3 text files in /home/cmccabe/Desktop/percent by matching the numerical portion of each file to lines 3,4, or 5 in /home/cmccabe/Desktop/analysis.txt. There will always be a match between the files. When a match is found each text file in... (2 Replies)
Discussion started by: cmccabe
2 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
VOP_RENAME(9)						   BSD Kernel Developer's Manual					     VOP_RENAME(9)

NAME
VOP_RENAME -- rename a file SYNOPSIS
#include <sys/param.h> #include <sys/vnode.h> int VOP_RENAME(struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp, struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp); DESCRIPTION
This renames a file and possibly changes its parent directory. If the destination object exists, it will be removed first. Its arguments are: fdvp The vnode of the old parent directory. fvp The vnode of the file to be renamed. fcnp Pathname information about the file's current name. tdvp The vnode of the new parent directory. tvp The vnode of the target file (if it exists). tcnp Pathname information about the file's new name. LOCKS
The source directory and file are unlocked but are expected to have their ref count bumped on entry. The VOP routine is expected to vrele(9) both prior to returning. The destination directory and file are locked as well as having their ref count bumped. The VOP routine is expected to vput(9) both prior to returning. ERRORS
[EPERM] The file is immutable. [EXDEV] It is not possible to rename a file between different file systems. [EINVAL] An attempt was made to rename . or .., or to perform an operation which would break the directory tree structure. [ENOTDIR] An attempt was made to rename a directory to a file or vice versa. [ENOTEMPTY] An attempt was made to remove a directory which is not empty. SEE ALSO
vnode(9) AUTHORS
This manual page was written by Doug Rabson. BSD
July 24, 1996 BSD
All times are GMT -4. The time now is 12:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy