Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Renaming batch by removing substring Post 303032188 by Xubuntu56 on Wednesday 13th of March 2019 09:36:01 AM
Old 03-13-2019
Renaming batch by removing substring

I wish to rename all files ending in .txt by removing .tex.

Currently I have

Code:
me@me-Inspiron-518:~$ ls
 a.tex.txt   bin   b.tex.txt   c.tex.txt   Desktop   Documents   Downloads   d.tex.txt   Music   Pictures   Public   Templates   Videos

Desired outcome
Code:
me@me-Inspiron-518:~$ ls
  a.txt   bin   b.txt   c.txt   Desktop   Documents   Downloads   d.txt   Music   Pictures   Public   Templates   Videos

I can print to stdout with echo *.txt | sed 's/.tex//g' but it doesn't rename the files.


Ubuntu 18.04.2; Xfce 4.12.3; kernel 4.15.0-45-generic; bash 4.4.19(1); Dell Inspiron-518
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing substring from a string

Hi. I want to remove a substring from a string. If I use the "tr" command, it doesn't seem to to what I want it to: echo './somestring.dat' | tr -d './' results in somestringdat I want it to remove only occurances of the string './', rather than the individual character. The result... (1 Reply)
Discussion started by: dmilks
1 Replies

2. UNIX for Dummies Questions & Answers

Batch Renaming: Change files' extensions in many sub-directories

Hi all - I'm trying to rename a large number of files all at once and need some help figuring out the command line syntax to do it. I've already done quite a bit of research with the rename and mv commands, but so far haven't found a solution that seems to work for me. So: The files exist... (10 Replies)
Discussion started by: dave920
10 Replies

3. Shell Programming and Scripting

removing items from a file with batch

Please assist with awk scirpts: I need to remove items from a file in a batch: The file that I will remove from has the following format: abc00tef:10.81.12.3 abc01tef:10.81.12.3 abc02tef:10.81.12.3 abc03tef:10.81.12.3 abc04tef:10.81.12.3 abc05tef:10.81.12.3 I have a file which... (5 Replies)
Discussion started by: amir07
5 Replies

4. Shell Programming and Scripting

batch renaming ...

hi all, given a path, for example : /<pwd>/artist/album/ what i would like to do is to rename the album directory like that : /<pwd>/artist/artist | album/ and i would like to do the latter for all the "artist" directories and for all the "album" directories that belong to an artist ... (4 Replies)
Discussion started by: OneDreamCloser
4 Replies

5. UNIX for Dummies Questions & Answers

Batch Renaming of Files

Hello all, thanks for your time (and this forum, what an awesome resource for newbs like myself!) Anyways, I've been given the task of importing content from a directory of about...7000 HTML files. They are all named appropriately and broken down by name depending on what book they belong too.... (8 Replies)
Discussion started by: gratefulhokie
8 Replies

6. Shell Programming and Scripting

script for renaming a batch of files

hi i have a folder full of files. some of the names are quite off because the dimensions were the same and i had to put a 'b' after the initial number so that it didnt overwrite. what i want is a script in unix to overwrite the filwe name leaving some of the title intact, e.g. below are some... (3 Replies)
Discussion started by: shabs1985
3 Replies

7. Shell Programming and Scripting

BASH Batch renaming insert additional zero into filename

Hi all, Wondering how this could be accomplished........ a directory contains sequentially numbered files from fw01 to fw999. How would I insert an additional zero so that the directory lists these files in a proper manner? (i.e. all double digit files from fw01 to fw99 would become... (3 Replies)
Discussion started by: putter1900
3 Replies

8. Shell Programming and Scripting

Need help in batch renaming files with bash shell script.

I have some 50+ files in the following format : abcd_vish_running_ZEBRA_20140818.dat_08-14-2014_23:08:23 abcd_vish_running_ZEB-RA_20140818.dat_08-14-2014_23:08:35 abcd_vish_running_ZEB_RA_20140818.dat_08-14-2014_23:08:37 abcd_vish_running_RI-NG_20140818.dat_08-14-2014_23:08:42... (5 Replies)
Discussion started by: SriRamKrish
5 Replies

9. Shell Programming and Scripting

Renaming file in batch

Hi guys, I need a script to change the file names e.g.:- below are the mentioned files, i want t0 change the last character of the name 00000.cdr with e.g bep01.smsc.191214210500-00000.cdr to bep01.smsc.191214210500-92311.cdr next file be like bep01.smsc.191214210500-92312.cdr # ls -ltr... (9 Replies)
Discussion started by: mfaizan40
9 Replies

10. Shell Programming and Scripting

Script for batch renaming

What is wrong with this script to rename batch of similar files? For example renaming all *.txt files to *.tab . $ for i in seq {01..10}; do touch ${i}.txt; done $ ./rename.sh *.txt txt tab Error: mv: ‘01.txt’ and ‘01.txt’ are the same file. Code is: #!/usr/bin/bash # renames.sh #... (6 Replies)
Discussion started by: yifangt
6 Replies
BTAG(1) 							    btag Manual 							   BTAG(1)

NAME
btag - A command line based multimedia tagger SYNOPSIS
btag [options] path1 [path2] [path3] ... DESCRIPTION
btag is a TagLib-based command line multimedia tag editor that attempts to automate the process of tagging a lot of files at once. It uses the tags found in the supplied files as well as interactive user input to determine new values for the tags. It can also optionally rename files and directories based on those new values. You can supply paths to files or directories to btag. Directories are recursively traversed and all files found are tagged. Directories are also handled differently in the sense that btag will attempt to keep information about the previously tagged files to provide sane defaults for all other files in the same parent directory. Only files with file extensions supported by TagLib are considered. OPTIONS
-D/--dry-run Don't do anything, just show what would have been done (dry run mode) -d/--dir-rename-format format Use format to rename the directories where the multimedia files were found -i/--input-filter filter Use filter as the input filter -f/--filter filter Use filter as both the input and the output filter -h/--help Display usage information and exit -n/--renaming-filter filter Use filter as the renaming filter -o/--output-filter filter Use filter as the input filter -r/--file-rename-format format Use format to rename the multimedia files -t/--title-locale locale Use locale for proper (although lax) locale-specific title casing INPUT AND OUTPUT FILTERS
btag supports input and output filters that are applied to the text fields (artist, album and song title). Those filters can protect against basic mistakes such as duplicate whitespace. Input filters are used on the tags as they are loaded from the multimedia files. This filtered information is used to provide suggestions to the user when the interactive tagger requests information for those text fields. If an output filter is configured, the user input is then filtered, and if the filtered text does not match the user input, the user is asked for confirmation. In most cases, the input filter should match the output filter (which is why the -f option is handy). You may choose to specify only an input filter, in which case the user input is not filtered. If you don't specify an input filter, though, the default input filter will be used. The currently available filters are: basic Provides basic filtering by removing duplicate or trailing whitespace, is the default input filter and the base for all other filters first_upper The first character in the field is uppercased, while all others are lowercased lower All characters are lowercased title The first character of each word is uppercased (with exceptions), while all others are lowercased upper All characters are uppercased The title capitalization algorithm will follow locale-specific context-insensitive rules depending on the value of the -t parameter. Note that strict title capitalization rules often depend on the context in which the words are used, the precise analysis of which is much beyond the scope of btag. The currently supported title locale specifications are: en English (default) es Spanish RENAMING FORMATS
If a format is specified with the -r option, the tagged multimedia files are renamed accordingly. Likewise, if the -d option is used, the directory in which multimedia files were tagged is renamed according to the specified format. The specified format is converted to a file or directory name using the following substitutions: %artist Artist name %album Album name %year Year of release %track Track number (only replaced by the -r option) %title Song title (only replaced by the -r option) Renaming happens after the tags are written, and it's relative to btag's working directory. For directory renaming, the last known artist, album and year information is used. Only directories that contain files that were tagged by btag are renamed. btag does not prevent you from overwriting existing files using the formats described here. RENAMING FILTERS
Renaming filters are used to ensure that the file and directory names generated using the renaming formats (if specified) are valid (safe) in the context of the current file system. The following renaming filters are currently available: conservative Conservative character replacements are performed, recommended for FAT32 file systems unix Generates file and directory names that should be valid in an Unix environment (default) EXAMPLE
Using title casing with English rules and sensible renaming formats generating FAT32-safe file and directory names: $ btag --file-rename-format '%track. %title' --dir-rename-format '%album (%year)' --filter title --title-locale en --renaming-format conservative /path/to/myalbum Using an input filter only: $ btag --input-filter lower /path/to/myalbum btag 2011-06-04 BTAG(1)
All times are GMT -4. The time now is 01:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy