Sponsored Content
Full Discussion: Remove prefix from filenames
Top Forums Shell Programming and Scripting Remove prefix from filenames Post 97010 by HLee1981 on Wednesday 25th of January 2006 11:09:06 AM
Old 01-25-2006
Question Remove prefix from filenames

I'm trying to put together a shell script that will append specific prefixes based on the content of filenames. I think I have this part down. However, I want to append before that part a process that will remove the current prefix before it renames the files with the new prefix.

For example, if all the files I want to rename, for example are:
---
ALPHANUM.ABCDEFG
ALPHANUM.HIJKLMNOP
ALPHANUM.QRSTUV
ALPHANUM.WXYZ
ALPHANUM.01234567890
---
and depending on the contents, if $[0-9] append the prefix "NUM." and $[A-Z] append prefix "ALPHA". The part where I'm stuck at is trying to figure out how to remove the "ALPHANUM." prefix before I do any appending.

Tried searching through the forums with "remove suffix, change suffix, remove prefix, change prefix," and "prefix" to get some examples, but did not spot anything I'm trying to do.

Please help.

Thanks!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

remove filename prefix

I've got a bunch of files called oldabc, olddef etc. i want to copy these to be abc, def.... I can do this with file extensions....but can get the logic to work for prefixes. All the files I am interested in have a prefix of 'old'. This loop is no good for me....it looks at the content... (2 Replies)
Discussion started by: peter.herlihy
2 Replies

2. Shell Programming and Scripting

Remove prefix using awk

Remove prefix using awk File: nawk -F"|" '{if ($1 ~ /^xyz./) print; else { gsub(.*\..*, \..*, $1) ;print }}' file Error: ouput required: (5 Replies)
Discussion started by: pinnacle
5 Replies

3. Shell Programming and Scripting

Remove Duplicate Filenames in 2 very large directories

Hello Gurus, O/S RHEL4 I have a requirement to compare two linux based directories for duplicate filenames and remove them. These directories are close to 2 TB each. I have tried running a: Prompt>diff -r data1/ data2/ I have tried this as well: jason@jason-desktop:~$ cat script.sh ... (7 Replies)
Discussion started by: jaysunn
7 Replies

4. Shell Programming and Scripting

Remove prefix per line in file

Hi, I'm using a .ksh script to split one file into multible files by checking for the prefix per line. It works perfekt (thanks again for anyone involved in helping me with that ;)), but I want to remove the prefix per line too. Means only the line information itself should remain in the... (7 Replies)
Discussion started by: spidermike
7 Replies

5. Shell Programming and Scripting

Remove filenames beginning with multiple dots

hi all, I want to remove filenames beginning with multiple dots.how I can do this. Thanks in advance (5 Replies)
Discussion started by: sriharsharavi
5 Replies

6. UNIX for Dummies Questions & Answers

find & remove characters in filenames

I have a group of files in different directories with characters such as " ? : in the file names. How do I find these files and remove these characters on mass? Thanks (19 Replies)
Discussion started by: barrydocks
19 Replies

7. Shell Programming and Scripting

Remove spaces in filenames

Hi, I have files like below, In files coming as spaces. Before transfering those files into ftp server. I want to remove the spaces and then can transfer the files into unix server. e.g: filenames are 1) SHmail _profile001_20120908.txt 2) SHmail_profile001 _20120908.txt 3) sh... (3 Replies)
Discussion started by: kirankumar
3 Replies

8. Shell Programming and Scripting

Remove files from subdirectories given a list of filenames

Dear all, I have a dir structure like main_dir At_nn Ag_js Nf_hc .... mcd32 mgd43... mcd32 mgd43... mcd32 mgd43... and each subdir (e.g. mcd32, mgd43) contains files. Now, i... (15 Replies)
Discussion started by: yogeshkumkar
15 Replies

9. Shell Programming and Scripting

How to remove filenames having the same extension.?

hi, i have a directory which contains some files and a subdirectory. i am writing only the files names to a file using the below code. ls -ltr | grep "^-" | awk '{print $NF}' > /home/file_list$$ cat /home/file_list$$ s1_abc.txt s2_def.xls s3_def.xls as you can see there is one .txt... (7 Replies)
Discussion started by: Little
7 Replies

10. Shell Programming and Scripting

Extract Uniq prefix from a start and end prefix

Dear All, assume i have a file with content: <Start>6000</Start> <Stop>7599</Stop> the output is: 6000 7000 7100 7200 7300 7400 7599 how should we use any awk, sed, perl can do this task, means to extract the uniq prefixes from the start and stop prefix. Thanks Jimmy (3 Replies)
Discussion started by: jimmy_y
3 Replies
cuebreakpoints(1)					      General Commands Manual						 cuebreakpoints(1)

NAME
cuebreakpoints - report track breakpoints from a CUE or TOC file SYNOPSIS
cuebreakpoints [ { -i format | --input-format=format } { --append-gaps | --prepend-gaps | --split-gaps } ] [ file ... ] cuebreakpoints --help DESCRIPTION
cuebreakpoints reports the track breakpoints found in CUE and TOC files, which are typically created by compact disc ripping software. The breakpoints are in a format usable by shnsplit (part of the shntool package). Three approaches to track pregaps are availabe: append (to previous track), prepend (to succeeding track), and split (from both preceding and succeeding tracks). The split approach can result in up to twice as many breakpoints being reported as there are tracks on the disc. The first track's pregap cannot be appended to the previous track, so it is prefixed to the track in both append and prepend modes. If you want the track without it, use the --split-gaps option. If no filenames are specified, cuebreakpoints reads from standard input, and an input format option must be specified. If one or more filenames is provided, but the input format option is not specified, the input format will be guessed based on each file's suffix (e.g., .cue or .toc). This heuristic is case-insensitive. OPTIONS
-h, --help displays a usage message and exits. -i format, --input-format=format sets the expected format of the input file(s) to format, which must be either cue or toc. --append-gaps appends pregaps to the end of the previous track. This is the default. --prepend-gaps prefixes pregaps to the beginning of each subsequent track. --split-gaps separates pregaps from both the preceding and succeeding tracks. If more than one of --append-gaps, --prepend-gaps, and --split-gaps are specified, all except the last encountered are ignored. EXIT STATUS
cuebreakpoints exits with status zero if it successfully generates a report for each input file, and nonzero if there were problems. AUTHOR
Cuetools was written by Svend Sorensen. Branden Robinson contributed fixes and enhancements to the utilities and documentation. SEE ALSO
cueconvert(1), cueprint(1) cuebreakpoints(1)
All times are GMT -4. The time now is 08:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy