How can I strip out a numeric prefix from multiple filenames?

Kim

I have >2000 files which are named like

123-FILENAME_TEXT_M101K_20150929.CSV

where 123 can be any three or four-digit number. The files are all within the same directory. I would like a script that removes the prefixing number and the dash. (i.e. the leading 123- should be removed from the example name)

I have tried mv **-FILENAME* FILENAME*. rename is not an available function

mmoisse

You could try something like this, it will remove everything before the first -

for file in *-*.CSV
do
   newName="${file#*-}"
   mv -- "${file}" "${newName}"
done

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I strip the whitespace from Pandas DataFrame headers?

How can I strip the file extension from a list full of filenames?

How can I strip namespaces out of an lxml tree?

How to strip non-numeric characters from BigQuery results

How can I send a Tmux prefix command from outside?

How can I change multiple filenames in different subdirectories in python?

How to strip out values from a javascript string

How can I remove leading numbers from filenames using prename?

How can I make this Javascript validation apply to multiple numeric fields?

How can I sum multiple Numeric textbox value?

How can I strip out all HTML from my string

How do I safely get multiple filenames from Zenity?

How can I strip in-line comments from a text reader

How to strip non-alphabetic, spaces and numeric characters from a string?

How can I strip dollar signs ($) from a field in Hive?

How can I strip out urls from a string in MySQL?

How can I split and select from an array of filenames in Powershell?

How can I strip any and all HTML tags from a string?

How to strip out an attribute from Javascript object

Strip prefix from variable - bash

How can I remove a numerical extension from an array of filenames?

How can I strip out a the base URL using JavaScript?

Can I use `std::path::Path`'s `strip_prefix` to replace a dynamic prefix?

How do I take multiple filenames from the Raku command line?

how can I strip the 00:00:00 from a date in python

How can I modify multiple filenames?

How can I strip leading zeros from multiple columns in a dataset?

How can I create a TensorFlow image dataset labelled by filenames from multiple directories?

How can I remove the first character from all filenames in a folder?